Search code examples
regexsearchnotepad++lookbehind

Regex Notepad++ Searching for certain instances


I have a large group of text files (.xml) that I'm looking to search and find.

Due to a conversion, certain letters (i and l) were dropped after a letter f.

Data contains instances of

  • "f re" fire
  • "diff cult" difficult
  • "ref ector" reflector

and many more cases.

where the dropped letter became a space.

I want to search for

f\s

but I want to eliminate it pointing out whole words like off, of, and if.

\soff\s
\sof\s
\sif\s

I have come up with a series, but I'm not sure how to string the regex code together.

(?<!\so)f\s
(?<!\si)f\s
(?<!\sof)f\s

Any help offered would be greatly appreciated, Thank you


Solution

  • How about:

    (?<!i|o)(?<!of)f\s
    

    This will match f\s only if it isn't preceded by i or o or of.

    I'm using two lookbehind because npp doesn't accept variable length lokkbehind.

    It doesn't match off ce (office).