只是不知道如何匹配 IF 和 If,但不知道 if 或前缀为 $ 的。
示例:
If True then // <- match
IF True then // <- match
if True then // <- don't match (lowercase i)
{SIF NOT DEFINED(SAAS)} // <- don't match (part of another word)
{$IFDEF DEBUG} // <- don't match (preceded with a $)
ChatGPT 建议:
\bIf\b(?!\$)
但是当之前有
$
时就不起作用了。
您不必在此处使用lookahead 或lookbehind,因为您只想将术语
If
和 IF
作为整个单词进行匹配。只需使用单词边界即可:
\bI[Ff]\b