Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: I want to replace a complex string using regex.

  1. #1
    Junior Member
    Join Date
    Jan 2023
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation I want to replace a complex string using regex.

    Hello guys,

    I want to replace

    Logger.info(className, dasd + "sadsd" );


    with

    Logger.info(className, dasd + "sadsd" + " [" + Thread.currentThread().getStackTrace()[1].getLineNumber() + "]");


    using regex.

    The dasd + "sadsd" part is random and there can be any text there, we print any log message there.

    How can I do it?

    There are 1000s of loggers in our code that I want to replace to add the Thread line....

    Thanks

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: I want to replace a complex string using regex.

    Also posted here: https://coderanch.com/t/767050/java/...x-string-regex

    Please read: http://www.javaprogrammingforums.com...s-posting.html
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Java String regex - Extract String Tag for its Value
    By Raj4Smile in forum What's Wrong With My Code?
    Replies: 0
    Last Post: May 12th, 2014, 08:47 AM
  2. Problem with String replace and CharSequence
    By Calii in forum Java Theory & Questions
    Replies: 3
    Last Post: October 4th, 2011, 07:32 PM
  3. [SOLVED] Replace String Method? Noobie :/
    By Usoda in forum What's Wrong With My Code?
    Replies: 7
    Last Post: September 18th, 2011, 10:58 AM
  4. Regex or String Algoritham
    By dileep24p in forum Algorithms & Recursion
    Replies: 4
    Last Post: July 7th, 2011, 08:34 PM
  5. [SOLVED] Replace Phrase in String
    By aussiemcgr in forum Java Theory & Questions
    Replies: 2
    Last Post: October 18th, 2010, 12:10 PM

Tags for this Thread