0

How to use regex in notepad++ to find two word within a set of consequent 10 lines?

wherever these 10 lines are in the long text file.

so I need the filter only succeeds if the two words are in a range of ten consequent lines

what will be regex expression for it?

  • Assuming your 2 words are `foo` & `bar`,use this: `.*\bfoo\b.*(?:\R.*){1,10}\bbar\b` – Toto Feb 08 '20 at 11:38
  • thanks a lot for your reply but this only works if i added the two words in order so if i put bar instead of foo that will not work..Is it possible to make the script catch this paragraph even if the words are exchanged ? – osamaelnino Feb 09 '20 at 07:15
  • Sure, use: `\bfoo\b.*(?:\R.*){1,10}\bbar\b|\bbar\b.*(?:\R.*){1,10}\bfoo\b` – Toto Feb 09 '20 at 11:45
  • Can we have a script that do the same but for patterns instead of words what i mean here i need to catch words foo and bar if I write in the script "fo" and "ar" ? – osamaelnino Feb 26 '20 at 07:54
  • It's too complex to give an answer in comment. Please, ask a new question where you explain what you want with examples and expected results, add what you've tried and explain what doesn't work. – Toto Feb 26 '20 at 10:40

0 Answers0