What workaround in Regex (Zotero) to ENG\s+DOGS matches ENG DOGS or ENGDOGS?

StackOverflow https://stackoverflow.com/questions/23306325

  •  09-07-2023
  •  | 
  •  

문제

Expression expects line breaks and spaces, but they couldn't appear too. 0 space possibility.

ENG\s+DOGS need to match:

ENG DOGS 

ENGDOGS 

ENG [line break]
DOGS
도움이 되었습니까?

해결책

This will do it:

/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»

다른 팁

You need to use the * quantifier instead.

ENG\s*DOGS

Regular expression:

ENG           # 'ENG'
 \s*          # whitespace (\n, \r, \t, \f, and " ") (0 or more times)
 DOGS         # 'DOGS'

The following quantifiers are recognized.

*      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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top