Celeb Glow
updates | March 14, 2026

Notepad++ Regex: Match all occurrences after another match

How to match all occurrences after another match?

For example: I want to replace all - after abc with space.

Input:

one-two-abc-three-four-five
six-seven-abc-eight-nine-ten
...

Output:

one-two-abc three four five
six-seven-abc eight nine ten
...

In Javascript is possible to use this regex: (?<=(.+abc.+))-, but the Positive Lookbehind seems not to be supported in Notepad++

Thanks.

PS: Feel free to correct the Title. I did my best, but I'm not native speaker.

1

2 Answers

This will work with any number of hyphens in the string.

  • Ctrl+H
  • Find what: (?:^.*abc|\G[^-\r\n]+)\K-
  • Replace with: # a single space
  • CHECK Match case
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

(?: # non capture group ^ # beginning of line .* # 0 or more any character but newline abc # literally abc | # OR \G # restart from last match position [^-\r\n]+ # 1 or more any character that is not hyphen or line break
) # end group
\K # forget all we have seen until this position
- # hyphen

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

1

I found this solution.

Find:
^(.+abc)(-([^-]*))?(-([^-]*))?(-([^-]*))?(-([^-]*))?(-([^-]*))?(-([^-]*))?$
Replace:
$1 $3 $5 $7 $11 $13

These caveats you need to be aware of:

  1. All wanted (replaced) occurrences of - are after the last occurrence of abc.
  2. (-([^-]*))? part of regex is repeated equally or more than max. count of - in a single line.
  3. There will be extra spaces on end of each line which has less - occurrences than (-([^-]*))? count in the regex
  4. Number after $ in replace expression is start by 1 and is +2 for each (-([^-]*))? occurrence.

Try this regex online at

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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