Welcome to RegexAdvice Sign in | Join | Help

RegEx Side

The light side the dark side and the regex side.
Regex Cheat Sheet

It seems that many people have a basic understanding of how a regular expressions works. Lots of people will ask me, and probably many of you, for help in writing regular expressions. A lot of these people have a basic idea of what they need when it is a simple regex. I would like to point those people towards a regular expression cheat sheet. Many people ask for regular expressions and can say what they are looking for in a regular expression. They will say something like:

<2 to 4 letters><optional space or dash><5 digits><optional space or dash><3 digits>

matching the following:
CS 10051 001
MATH 23021-012

not matching the following:
A 10051 001
MATH 23021_012

From this simple description and a regex cheat sheet a basic regex can be made. There are obviously other considerations like the context of the strings, but a lot of people can state this much information. This makes creating the regex easy, and a lot more people should go and get some basic resources and learn to write regular expressions. You will be glad you did.

Check out my blog. It is where I blog regularly.
Posted: Tuesday, February 6, 2007 12:52 PM by Brendan


Halley Short said:

thank you for the cheat sheet

# February 13, 2007 7:55 PM

Henrik said:

Thanks a lot! i was just about to write a document like this but now i dont have to. Have u considered making a more comprehensive examples list?
# March 8, 2007 4:16 AM

Brendan said:


   Yes I am working on a new one in my spare time. I need to get around to finishing it. It is nearly done, I just don't have much free time.

# March 8, 2007 8:26 AM

Mike said:

Thanks for this, I really appreciate it :)
# March 9, 2007 9:27 AM

Venu said:

Thank you for the cheat sheet. I really appreciate your work to prepare this sheet. Hope we can see your examples work soon :)
# March 30, 2007 3:34 PM

Mark said:

A great help and time saver! thank you.
# April 3, 2007 2:19 PM

Brendan said:

Thanks, but I did not make the sheet I am talking about. It is the cheat sheet for http://Regexlib.com As I mentioned in an earlier comment I am working on another one. It is almost done I just have to get around to doing something with it. I will blog about the new one when I complete it. I will also try to contact the people who comment here to let them know about the new one.

# April 4, 2007 8:38 AM

Prashant Malik said:

Thanks for the cheat sheet i really appreciate it
# April 17, 2007 4:23 AM

craig said:

struggling to validate a phone number, can anyone help?
# April 20, 2007 3:36 PM

Brendan said:

Craig, check out the regular expression construction advice forums. That is a great place to get help with any regular expression.

# April 20, 2007 4:56 PM

channakeshav said:

# August 3, 2007 2:18 AM

Lokesh said:

Thanks a lot for providing a Cheat Sheet.
# October 3, 2007 5:54 AM

Brendan said:

I recommend heading over to my aspadvice blog where I actually do my blogging. I've been blogging there and not here.


# July 21, 2008 1:28 PM

Norm said:

You state a problem in using regex to start this thread but don't show the solution. I'm trying to skip an option space in the second position of a string and can't get it to work.
# September 27, 2008 11:16 AM

clean credit said:

I only wish I had found it sooner.

# October 15, 2009 3:16 AM
Leave a Comment





Enter the code you see below

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS