开发者

Regex pattern search in TextPad fails, works in Visual Studio

开发者 https://www.devze.com 2022-12-07 23:50 出处:网络
I\'m trying to use TextPad to search for a regular expression in several files. I have a simple pattern but it doesn\'t work in TextPad.It works fine in Visual Studio.

I'm trying to use TextPad to search for a regular expression in several files. I have a simple pattern but it doesn't work in TextPad. It works fine in Visual Studio.

A开发者_开发知识库nyone have any ideas?

I'm searching for:

hosted.mysite.com or host.mysite.com

using the pattern:

(hosted|host)\.mysite\.com


Use something like this

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


try this:

 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.


In Textpad you need to escape some characters, such as parenthesis and pipes.

In your case, what you need is this:

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

Note: you need to escape dots as well.


Textpad's POSIX regexes are good, but even better results could be achieved by installing the Win GNU util grep and adding a cmd /c "Prompt for parameters " , "Capture output" command: thus you could have full Find in files with even Perl regexes: grep -nhPr "CoolRegexToSearchWith" C:\MyDir\ToSearchRecursivly

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号