Regular expression to find two strings anywhere in input

后端 未结 7 520
情话喂你
情话喂你 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 is fairly easy on processing power required:

    (string1(.|\n)*string2)|(string2(.|\n)*string1)

    I used this in visual studio 2013 to find all files that had both string 1 and 2 in it.

提交回复
热议问题