In linux sed, we can use the matched regex using “&”. Can i do the same in notepad++ ? in find and replace, can i use the matched string by regex to be used in replace section ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Update
Notepad++ version 6.x has been released, using PCRE as its regex engine for find-and-replace. You can now refer to the entire match in the replacement string using
$0or$&(but not\&or&), without having to capture the entire pattern anymore.For example, replacing
foowith$&bar$&yieldsfoobarfoo.Old answer
There isn’t a way to do this in Notepad++ regex I’m afraid. You have to manually capture the entire pattern and use
\1in the replacement field.As an example, for the following sed command:
Which outputs
foobarfoofor the input stringfoo, the equivalent in Notepad++ regex is:Find:
Replace with: