tags:

views:

219

answers:

11

My applications frequently use Regex for input validation.

Most of the Regex values that I need are pretty common (email address, basic types, etc). What is a good place to both learn about Regex creation and find common Regex patterns?

+7  A: 

http://regexlib.com

Travis Collins
+1  A: 

I like the (Python Regular Expression Howto)[http://www.amk.ca/python/howto/regex/] it provides a (reasonably) quick reference as well as some interactive examples showing regexes in action.

Obviously, this is a little python centric, though python uses a regex syntax shared by Perl, Java, etc.

Aaron Maenpaa
+1  A: 

I use this one a bunch: http://www.regular-expressions.info/

Jeremy Reagan
+6  A: 

I have this cheat sheet pinned to my cubicle wall...

^   Start of String
$   End of String
.   Matches any single char, but not line breaks
-   Indicates a range. "0-3" will match 0,1,2, or 3
[]  Character class. "gr[ae]y" will match "gray" or "grey"
|   Alternation (or) "thisPattern|thatPattern" will match either. 
?   Preceeding optional. "colou?r" will match "color" or "colour"
*   Matches the preceeding token 0 or more times. "a*" will 
    match "", "a", "aaa", or "abc"
{}  Number of specific matches "(abc){2}" will match "abcabc" but not "abcdabc"
()  Grouping operator

and a program called RegexDesigner to test them.

StingyJack
A cheat sheet is a great idea!
pearcewg
+8  A: 

I like the explanations at http://www.regularexpressions.info

Vinko Vrsalovic
Yes, a great site for introduction or reference.
harpo
A: 

http://regex.larsolavtorvik.com/ There's this cool tool in which you can test your regular expressions online as implemented in different languages (PHP/Perl/JavaScript). It's nice for tesing. For each language you have a cheatsheet reference right beside the tool. It's great because it's both a cheatsheet and a testing tool. I like to craft my regular expression in there.

http://www.regular-expressions.info/tutorial.html This is the site of the RegexBuddy tool which I highly recommend. There's a cool tutorial in there, in which I learned most of what I know about regular expressions.

Lepu
A: 

I find that a lot of people are using my Regular Expression Tester which allows the testing of Regular Expressions using the .NET RegEx classes.

For general information www.regular-expressions.info is good.

Mitchel Sellers
+2  A: 

Try Regular-Expressions.info. They also sell tools but the tutorials are pretty good.

DaveE
+1  A: 

I've found Regular-Expressions.info to be most helpful. They also include examples for different languages.

jamesaharvey
+1  A: 

stackoverflow.com is also not bad ;-)

Edit http://stackoverflow.com/questions/tagged/regex

Tim
If only you had added a URL to SO articles tagged regex...
Michael Dillon
That is easy enough.
Tim
+2  A: 

Use a regular expression animator to see how they work. There are several different forms of notation for regular expressions, for instance SQL notation versus UNIX notation, so don't get hung up on the coding. Learn what is actually taking place when a match is made.

Here are a couple of possibilities

Michael Dillon