简体   繁体   English

TextPad中的正则表达式模式搜索失败,适用于Visual Studio

[英]Regex pattern search in TextPad fails, works in Visual Studio

I'm trying to use TextPad to search for a regular expression in several files. 我正在尝试使用TextPad在多个文件中搜索正则表达式。 I have a simple pattern but it doesn't work in TextPad. 我有一个简单的模式,但它在TextPad中不起作用。 It works fine in Visual Studio. 它在Visual Studio中工作正常。

Anyone have any ideas? 有人有想法么?

I'm searching for: 我正在寻找:

hosted.mysite.com or host.mysite.com

using the pattern: 使用模式:

(hosted|host)\.mysite\.com

使用这样的东西

\(hosted\|host\).mysite.com

尝试这个:

 host\(ed\)?\.mysite\.com

Not every text editor uses the same regex/conventions. 并非每个文本编辑器都使用相同的正则表达式/约定。 A regex you may get to work in Visual Studio won't necessarily work in Eclipse, Netbeans, or some other IDE or text editor. 您可能在Visual Studio中工作的正则表达式不一定适用于Eclipse,Netbeans或其他IDE或文本编辑器。

In Textpad you need to escape some characters, such as parenthesis and pipes. 在Textpad中,您需要转义一些字符,例如括号和管道。

In your case, what you need is this: 在您的情况下,您需要的是:

\(hosted\|host\)\.mysite\.com

Note: you need to escape dots as well. 注意:您还需要转义点。

Textpad的POSIX正则表达式很好,但是通过安装Win GNU util grep并添加cmd / c“参数提示”,“捕获输出”命令可以实现更好的结果:因此你可以在文件中使用甚至Perl正则表达式:grep -nhPr“CoolRegexToSearchWith”C:\\ MyDir \\ ToSearchRecursivly

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM