I'm trying to create a macro in Notepad++ to find IP addresses which include a % symbol.

So, I am trying to find IP addresses that meet this criteria:


That's it, I have tried many different regex variations and can find the IPs without issue, but I cannot seem to append %2 to the search; every way I have tried even with ASCII codes fails.

I have to iterate through all the 10.x.x.x%2 and change them to %1.  The gotcha is that I have a bunch of 10.x.x.x%1's in the same file and need those to remain.

By the way, this is a configuration from an F5 device, and the % symbol is how we distinguish different route domains.

  • What regex did you try? 10\.\d+\.\d+\.\d+%2 works for me in Notepad++ without problems... – mihi Aug 30 '17 at 18:32
  • That didn't work for me in version 7.3.3. – hubdows Aug 31 '17 at 14:13
  • Ctrl+H
  • Find what: (10(?:\.\d{1,3}){3})%2
  • Replace with: $1%1
  • Replace all


(               : start group 1
  10            : literally 10
  (?:           : start non capture group
    \.\d{1,3}   : a dot followed by 1 to 3 digits
  ){3}          : group must appear 3 times
)               : end group 1
%2              : literally %2
  • Check regular expression
  • DO NOT CHECK . matches newline


$1      : content of group 1
%1      : literally %1

I've assumed there are only IP addresses in each line. If you want to match specifically IP addresses, remplace (?:\.\d{1,3}){3}) with (?:\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}) so:

  • Find what: (10(?:\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})%2
  • Replace with: $1%1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.