I know using a simple negative lookbehind
#(?<!first word)\r\nsecond word#s
This will not find second word in
some text
first word
second word
some text
and matches as expected in
some text
second word
some text
It also matches here, but it should not
some text
first word
any other text
second word
some text
How do I need to modify my regular expression to meet the requirements ?
I tried #(?<!first word).*second word#s, but it always matches.
I need this to search through many files in notepad++
Your first regexp is matching 3rd example as if it is looking a string that is not
first wordand which has asecond wordas a next string.The last regexp would match everything because of
.*which is matching everything.I'm suggesting to add a
.*in negative lookbehind.I don't know which editor you are using, so please correct if it's not corresponding to your's regexp syntax.
I would search a maximal long string which has not
first wordto be proceeded bysecond wordlike this^(?!.*first word.*)\r\nsecond wordI hope it will work.
Good luck!