Reg Ex解析错误 - 太多了)

Chr*_*ing 1 .net regex

使用.NET中的正则表达式与模式^%[^%]+%\Z和字符串"few)few%"我得到错误 - System.ArgumentException: parsing "few)few%" - Too many )'s.

Dim match As System.Text.RegularExpressions.Match = System.Text.RegularExpressions.Regex.Match("^%[^%]+%\Z", "few)few%")
Run Code Online (Sandbox Code Playgroud)

问题是什么?我是否需要在任何输入表达式中将括号转义为reg ex?

(我正在尝试确定字符串在字符串的开头和结尾是否具有通配符%但不在字符串的其他位置)

Ais*_*ina 5

不,您的输入不必转义.你只是错误的方式让你的论点.

来自MSDN:

public static Match Match(
    string input,
    string pattern
)
Run Code Online (Sandbox Code Playgroud)