Regex, Regexp or Regular expressions are a special syntax used in programming to search for patterns in a text. They are often used to validate form input, or for intelligent search and replace. The Regex markup looks very complicated as it is often a long string of characters.
(\d{5}([\-]\d{4})?)
This Regex pattern validates the US-postal code format
Regex itself follows a very logical pattern and can be very powerful and much easier than other attempts at parsing text. Whether you need simple format conversion (US to European numbers, “–” to “—”), email address validation in web forms, or validate if the password your users create matches your required format, Regex can be of help.
Learn:
Watch Lea Verou’s Talk
The internet is full of resources for learning this wizardry. A good starting point is Lea Verou’s celebrated presentation at O’Reilly’s Fluent Conference 2012: /Reg(exp){2}lained/: Demystifying Regular Expressions
Try it out at Regexplained
She also created Regexplained, a nifty tool to help you learn.
Learn it step by step at RegexOne
RegexOne is a short little course that helps you earn Regex with simple, interactive examples and a comprehensive list of exercises.
Reference
HTML5 Pattern
Don’t reinvent the wheel. Learn from and build on existing patterns at html5pattern.com.
Mozilla Developer Network – Regex Reference
The group at mozilla has put together a Regex reference that will come in handy, especially if you work with JavaScript.
Apps
Oyster ($4.99)
Oyster calls itself an IDE for Regex. It serves as a reference, a development environment as well as a library for your Regex patterns. It also allows you to export your patterns for a large number of programming languages. (Unfortunately Regex has been implemented slightly different across languages). You can get Oyster on the Mac App Store.
Reggie (Free)
Reggie is an open-source Regex tester/viewer.
Too complicated?
Try VerbalExpressions by Jehna. VerbalExpressions create RegEx using natural language in JavaScript.
Have you used Regex?
What was your experience? How did you learn it? Do you find it useful?