Regular expression to find two strings anywhere in input

后端 未结 7 497
情话喂你
情话喂你 2020-11-30 20:34

How do I write a regular expression to match two given strings, at any position in the string?

For example, if I am searching for cat and mat

相关标签:
7条回答
  • 2020-11-30 21:05

    This works for searching files that contain both String1 and String2

    (((.|\n))String1((.|\n))String2)|(((.|\n))String2((.|\n))String1)

    Match any number of characters or line fields followed by String1 followed by any number of characters or line fields followed by String2 OR Match any number of characters or line fields followed by String2 followed by any number of characters or line fields followed by String1

    0 讨论(0)
提交回复
热议问题