.NET Regex 类的运算符优先级记录在哪里?
Where is the order of operator precedence documented for the .NET Regex class?
I see this, but that's for JScript.
Also, it appears this is not affected by RegexOptions.ECMAScript
, but confirmation would be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个问题很久以前就有人问过,但没有得到解答。
.Net 正则表达式运算符优先级在正则表达式语法页面底部定义 1。
This was asked a long time ago, but not answered.
The .Net regex operator precidence is defined at the bottom of the Regular Expression Syntax page 1.
我认为真正的答案并不像您想要的那么简单。简短(且不完整)的答案只是“所有表达式都是从左到右计算的”......
对于长答案,请转到此处。
http://msdn.microsoft.com/en-us/library/e347654k.aspx
编辑:忘记回答问题的第二部分。
关于RegexOptions.ECMAScript,您可以参考这些文档:
http://msdn.microsoft.com/en-us/library/yd1hzczs.aspx
看起来“订单”没有受到影响,但可能还有其他问题。这些文档很好地说明了差异。
I don't think the real answer is as simple as you'd like. The short (and incomplete) answer is simply "all expressions are evaluated left to right" ...
For the long answer go here.
http://msdn.microsoft.com/en-us/library/e347654k.aspx
Edit: Forgot to answer the second part of your question.
With regard to RegexOptions.ECMAScript, you can reference these docs:
http://msdn.microsoft.com/en-us/library/yd1hzczs.aspx
It doesn't look like "order" is affected, but there could be other issues. The docs do a good job of illustrating the differences.
为了澄清 Donald Rich 的回答,Microsoft 尚未提供 .NET Regex 引擎的记录优先级顺序。不过,他们确实记录了旧 Visual Studio 2010 JScript 引擎的优先顺序,这似乎与 .NET 的行为方式相符。我在下面复制了它,以防 Microsoft 文档消失。
来自 正则表达式语法 >优先顺序:
To clarify Donald Rich's answer, Microsoft hasn't provide a documented order of precedence for the .NET Regex engine. However, they did document the precedence order for the old Visual Studio 2010 JScript engine, which seems to match how .NET behaves. I've duplicated it below in case the Microsoft docs disappear.
From Regular Expression Syntax > Order of Precedence: