A Crash-Course in Regular Expressions
Hi everyone. I originally released this screencast back when this blog only had about two hundred subscribers. Lately, many of our new readers have been asking me about using regular expressions. So, I decided to bump this one back to the top. I hope you enjoy it!
To a novice web developer, regular expressions look like the most scary thing on the planet. Who could possibly dismantle such a block of code and decipher its meaning? Luckily, its bark is much worse than its bite. You’ll quickly find that regular expressions are rather straight-forward and easy to understand – once you learn the syntax.
Click on the “Toggle” to view the video in full screen.
Additional Resources
-

Regular Expressions Cheat Sheets
Whether you’re searching strings or validating input fields, the use of regular expressions will save you a great deal of time. I found a great cheat sheet from AddedBytes.com that should save you a great deal of time. It’s a free PDF download, so get to it!
-

Using Regular Expressions with PHP
This site specializes in all things related to “regular expressions”. It should be your first stop on your learning question.
-

PHP Regular Expression Tutorial
Regular expressions are a powerful tool for examining and modifying text. Regular expressions themselves, with a general pattern notation almost like a mini programming language, allow you to describe and parse text. They enable you to search for patterns within a string, extracting matches flexibly and precisely.
-

Using Regular Expressions with PHP
In this article I will show you how to use PHP regular expressions in your own PHP scripts.


















Bad choice in pictures for open
Nice tutorial, thanks
thanks for the nice tut, explained everything
at the part where the regex for email addreses is done there a missing $ sign at the end,…
so it not only will valitate “sitemanager@themeforest.net” but also “sitemanager@themeforest.net something else here” ??
here some examples which would be valid email addresses but invalid acording to the used regex,…
email@some-site.com
email@blog.somesite.com
email@somesite.co.uk (same ideea as above)
i think this would be a better regex for emails,.. please correct me if im wrong
\^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$\
Nice!
Jeff, I really love your screencasts, you’re really good at explaining things!
Keep up the good work
Another excellent video tutorial clearing up my confusion over Regular Expressions. I have “Mastering Regular Expressions” by Friedel and got lost somewhere in there. You have opened another door for me. Thanks
It is such a relief to have discovered your tutorials which do improve my learning curve drastically
Outdated tutorial.
Another great eye opener.
Thank you very much.
Thanks Jeffrey, I was making a contact form today and this came in handy.
\^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$\
^^
this would work but you forgot to close scope the .***
so:
/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.{[a-zA-Z],{2,4}}$\