gpt4 book ai didi

regex - 为什么 Visual Studio 使用如此奇怪的正则表达式语法

转载 作者:行者123 更新时间:2023-11-30 18:40:39 25 4
gpt4 key购买 nike

Visual Studio 使用如此奇怪的语法(例如在搜索/替换对话框中)有什么原因吗?

不是写 \s*(\w+) = new Process\(\) 我必须写 :b*{:a+} = new Process\(\).
我一直在为这种语法而苦苦挣扎——尤其是因为正常的 .NET语法是前者。

这是两种语法之间的不完整比较:

What            Visual  .NET   Comment
Studio
----------------------------------------------------------------
Tab/Spaces :b \s Either tab or space
Alphanumeric :a \w ([a-zA-Z0-9])
Subexpression {} ()
Substitution \n $n Substitutes the substring matched
by a numbered subexpression.
Backreference \n \n Matches the value of a numbered
subexpression.
----------------------------------------------------------------

有关详细信息,请参见此处(Visual StudioC#)。

这有什么原因吗?它是历史的吗?有什么好处吗?

最佳答案

我引用编码恐怖:

However, you're in for an unpleasant surprise when you attempt to actually use regular expressions to find anything in Visual Studio. Apparently the Visual Studio IDE has its own bastardized regular expression syntax. Why? Who knows. Probably for arcane backwards compatibility reasons, although I have no idea why you'd want to perpetually carry forward insanity. Evidently it makes people billionaires, so who am I to judge.

http://www.codinghorror.com/blog/2006/07/the-visual-studio-ide-and-regular-expressions.html

关于regex - 为什么 Visual Studio 使用如此奇怪的正则表达式语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7899355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com