表达式需要换行符和空格,但它们也不会出现。 0
空间可能性。
ENG\s+DOGS
需要匹配:
ENG DOGS
ENGDOGS
ENG [line break]
DOGS
答案 0 :(得分:1)
您需要改为使用*
量词。
ENG\s*DOGS
正则表达式:
ENG # 'ENG'
\s* # whitespace (\n, \r, \t, \f, and " ") (0 or more times)
DOGS # 'DOGS'
以下量词被认可。
* Match 0 or more times
+ Match 1 or more times
? Match 1 or 0 times
{n} Match exactly n times
{n,} Match at least n times
{n,m} Match at least n but not more than m times
答案 1 :(得分:1)
这样做:
/ENG\s*DOGS/
Match the characters “ENG” literally «ENG»
Match a single character that is a “whitespace character” (spaces, tabs, and line breaks) «\s*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Match the characters “DOGS” literally «DOGS»