^[\x00-\x7F]+$- 匹配完全由 ASCII 字符组成的字符串。[^{}$]* 匹配零个或多个不同于{,}和 的字符$。因此,第二条规则匹配任何字符串。如果这是您的意图,只需使用第一个正则表达式。如果您想匹配任何纯 ASCII 字符串(不包括 ){,}并$使用^(?=[\x00-\x7F]+$)[^{}$]*$解释-------------------------------------------------------------------------------- ^ the beginning of the string-------------------------------------------------------------------------------- (?= look ahead to see if there is:-------------------------------------------------------------------------------- [\x00-\x7F]+ any character of: '\x00' to '\x7F' (1 or more times (matching the most amount possible))-------------------------------------------------------------------------------- $ before an optional \n, and the end of the string-------------------------------------------------------------------------------- ) end of look-ahead-------------------------------------------------------------------------------- [^{}$]* any character except: '{', '}', '$' (0 or more times (matching the most amount possible))-------------------------------------------------------------------------------- $ before an optional \n, and the end of the string