Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8983777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:55:29+00:00 2026-06-15T20:55:29+00:00

I am looking for the regex which will let me use search replace to

  • 0

I am looking for the regex which will let me use search replace to add 2 lines of code to all java methods in file using Notepad++

Before:

  public void startProcessing() {
      ..............
      ..............
               }

After:

public void startProcessing() {

  logger.info( "Entering into startProcessing" );
  ..............
  ..............
  logger.info( "Exiting startProcessing" );
           }

Is this possible, if yes can anyone help me with the code… or guide me on any other possible way to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:55:31+00:00Added an answer on June 15, 2026 at 8:55 pm

    To start with the “bad news”, you won’t be able to insert the “Exiting” line unless you have a much-better fingerprint to match against. With your current code-sample, the best you can match against is } and, as a wild guess, there are probably a lot of closing-curly-brackets throughout your code.

    To insert the “Starting” line is do-able, but the robustness depends on your input.

    If you will always want to replace the same line as in your sample code (or the same format but different function name), you could do the following in the Find+Replace menu:

    Find:

    public void startProcessing() {
    

    Replace:

    public void startProcessing() {\n\tlogger.info("Entering into startProcessing");
    

    Search Mode: Extended

    If you want to dynamically do the replacement with a non-hardcoded function name, you could try the following:

    Find:

    (public void )([a-zA-Z0-9_$]+)(.*)
    

    Replace:

    \1\2\3\n\tlogger.info\("Entering into \2"\);
    

    Search Mode: Regular Expression

    This “dynamic” method will require whatever methods you’re searching for the be declared in the same format though, public void functionName.... I’ve used [a-zA-Z0-9_$] as the character-set for the function names, but you can adjust this to suit your needs.

    UPDATE (ignore get/set methods)
    To ignore get/set methods, such as getFieldValueUnits() or setFieldValueUnits(int val), you can use the following Find value (the Replace is the same-as-above):

    (public void )(?!get|set)([a-zA-Z0-9_$]+)(.*)
    

    This will match all functions that do not start with get or set (and are declared as public void, as above).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a regex to search my python program to find all lines
I am looking for REGEX which will give me data along with the end
I'm looking for a Perl regex that will capitalize any character which is preceded
I need a regex which will do the following Extract all strings which starts
I'm looking for a regex expression that will add an attribute to an element
I'm looking a symbol regex in PHP that will check submitted usernames and reject
I'm looking for a regex to remove all trailing asterisks and all asterisks inside
Let's say I have this string: 3+5+6+2^5+9+1+2+32^2+10^10 I want to replace all occurrences of
I'm looking around for a RegEx that can help me parse an nquad file.
I have been looking around for a regex expression that will spit out just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.