Regex 正则表达式:匹配不包含特定字符串
通过使用正则表达式,我希望获得出现以下字符序列的所有索引:Regex 正则表达式:匹配不包含特定字符串,regex,Regex,通过使用正则表达式,我希望获得出现以下字符序列的所有索引: FORALL ... in ... : //“FORALL”和“in”之间可能有空格和非单词字符,如“,” 例如: 找到以下三个: 对于所有我你可以试试这个正则表达式吗?(这是一个文本字符串) "(^FORALL[<=|>=|<|>|==|!=](?!.*in).*in$)((?!.*\\:).*\\:$ )" ^(FORALL [^<=>,: ]+) *[<=>,]+ *([^&
FORALL ... in ... :
//“FORALL”和“in”之间可能有空格和非单词字符,如“,”
例如:
找到以下三个:
"(^FORALL[<=|>=|<|>|==|!=](?!.*in).*in$)((?!.*\\:).*\\:$ )"
^(FORALL [^<=>,: ]+) *[<=>,]+ *([^<=>,: ]+)\s+in\s+([^,:]+)[^:]*:$
^ # Beginning of string
( # 1st capture begins
FORALL # Match FORALL and a space
[^<=>,: ]+ # Any characters except <=>,: or space
) # 1st capture ends
* # Any spaces
[<=>,]+ * # Any characters of <=>, followed by any spaces
( # 2nd capture begins
[^<=>,: ]+ # Any characters except <=>,: or space
) # 2nd capture ends
+in + # Match in surrounded by spaces
([^,:]+) # Match any non , or : characters
[^:]*: # Match any non : characters, then match a :
$ # End of string
$1,$2 in $3: