How do I find multiple values on the same line in any permutation using Notepad++?

Using lookahead is much more efficient and can deal with any number of alternations without increasing complexity:

  • Ctrl+F
  • "Find what": ^(?=.*\b35=D\b)(?=.*\bEUR/USD\b)(?=.*\b150=8\b).+$
  • Check "Match case"
  • Check "Wrap around"
  • Check "Regular expression"
  • Uncheck ". matches newline"
  • Find All in Current Document

Explanation:

^               # Beginning of line
  (?=           # Start positive lookaead, make sure we have after:
    .*          # 0 or more any character but newline
    \b          # Word boundary to be sure not matching 135=DATA
    35=D        # Literally
    \b          # word boundary
  )             # End lookahead
  (?=           # Start positive lookaead, make sure we have after:
    .*          # 0 or more any character but newline
    \b          # Word boundary
    EUR/USD     # Literally
    \b          # Word boundary
  )             # End lookahead
  (?=           # Start positive lookaead, make sure we have after:
    .*          # 0 or more any character but newline
    \b          # Word boundary
    150=8       # Literally
    \b          # Word boundary
  )             # End lookahead
  .+            # One or more any character but newline
$               # End of line

Screen capture:

Enter image description here


To match only those lines where all three strings exist, you can use the alternate | operator and group (...) your patterns to build a regex for all possible permutations:

(35=D.*EUR/USD.*150=8)|(35=D.*150=8.*EUR/USD)|(EUR/USD.*150=8.*35=D)|(EUR/USD.*35=D.*150=8)|(150=8.*35=D.*EUR/USD)|(150=8.*EUR/USD.*35=D)

A readable version with added linebreaks:

(35=D.*EUR/USD.*150=8)|
(35=D.*150=8.*EUR/USD)|
(EUR/USD.*150=8.*35=D)|
(EUR/USD.*35=D.*150=8)|
(150=8.*35=D.*EUR/USD)|
(150=8.*EUR/USD.*35=D)

This would match all lines where a combination of 35=D, EUR/USD and 150=8 (and possible text inbetween) is present. In this sample text, only the last three lines would have a match (button "Find All in Current Document"):

some text 35=D
some text EUR/USD more text 150=8
some text 35=D more text EUR/USD more text 150=8
some text EUR/USD more text 35=D more text 150=8 more text
some text 150=8 more text EUR/USD 35=D more text


screenshot