开发者

Regular Expression Tools [duplicate]

This question already has answers here: Closed 13 years ago.

Possible Duplicate:

Regex Testing Tools

What sorts of tools do other programmers use when creating regular expressions?

I use The Regex Coach but it is sometimes a little slow when dealing with larger expr开发者_JS百科essions.


Regex Buddy of course!

It supports just about every possible flavour of Regular Expressions, including .NET, Perl, PCRE, JavaScript, POSIX BRE etc. Which is usually the hardest part (My problem is usually to find out how to formulate this regular expression in such a way that JavaScript understands it).

The best thing is that it can immediately output the code for your specific language. Since I'm a bit lazy that comes in handy ;-)


My mind and PowerShell for testing, mostly:

PS Home:\> $re = '([!?])\1+'
PS Home:\> 'hi!!!!','Hm','foobar??' | %{ $_ -match $re }
True
False
True


I can think of 2 problems with this approach:

  1. Not all tools use regular expressions in the same way. So you have to select the dialect that is supported by the tool targeted.

  2. Regular expressions are typically harder to read then to write. So you should go with the simplest thing that does the job, and comment it to convey your intentions.

That in mind, the best way is to play with the target tool, and not to rely to a wizard of some sort.


For me, I use Python to test regex for most cases and JavaScript shell sometimes.


I use irb.


Regulator or tkcon.


I see Ruby and Python answers, so I'll chip in. Does no one do it old school anymore?

$ perl -pe 'print if /test regex/'


grep at the most basic level, awk for more complex processing.


I like this one: http://regex.larsolavtorvik.com/

Useful for PHP and Javascript as well.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜