If I use a long regular expression in Notepad++, i.e.:
^([^ ]+) ([^ ]+) ([^ ]+) (\[.*?\]) (".*?") (".*?") (".*?") (".*?") (\d+) (\d+) (\d+)$
(this is for turning an Apache log lines from space-separated to tab-separated)
then I can't successfully use more than nine backreferences for replacing, as \10
yields the content of the first captured group plus a literal "0".
I tried with $10
, but that gives the same result.
Using Regex to find and replace text in Notepad++ In all examples, use select Find and Replace (Ctrl + H) to replace all the matches with the desired string or (no string). And also ensure the 'Regular expression' radio button is set.
A normal “Find and Replace” can't do that, but it's possible with “Regular Expressions”. In Notepad++ press Ctr+H to open the “Find and Replace” window. Under Search Mode: choose “Regular expression” and then check the “matches newline” checkbox. You should see closing </p> tags at the end of each line.
FYI Notepad++ supports “PCRE” (i.e. PERL Compatible Regular Expressions) using Boost's RegEx library which is different from the PCRE and PCRE2 libraries.
To replace text in Notepad++, follow the steps below. Open the text file in Notepad++. In the top menu bar, click Search and select Replace. In the Replace window, on the Replace tab, enter the text you want to find and the text you want to use as a replacement.
You can use curly braces for this:
${10}
For reference, Notepad++ uses boost::regex
, and you can find its substitution pattern docs here: Boost-Extended Format String Syntax. This replacement mode allows for more complex expressions (like conditionals and common Perl placeholders) in the replacement pattern.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With