Some people, when confronted with a problem, think:

I know, I’ll use regular expressions.

Now they have two problems.

Jamie Zawinsky

Funny one, uh? Well, I bet you are here cause you’re in trouble. If not, you’re just sadistic. I like you 😀


Anyways, I’m just writing down a quick dotted list for easy consultancy as my laziness law says a bookmark is less effort than Googling around. Mind that specific rules may vary from a programming language to another.

^ Beginning of the string
$ End of the string
[abc] Any of the characters between the brackets
[^abc] Any character BUT those between the brackets
[a-z] Lowercase letters from a to z
[A-Z] Uppercase letters from A o Z
[0-9] Digits from 0 to 9
. At lest one of the preceding character
* Zero or more
? Zero or one
{n} Exactly n occurrences
{n,m} n to m occurrences
{n,} At least n occurrences
{,n} Less than n occurrences
\s Whitespace character (TABs, new lines, …)
\S Non whitespace character
\0 Null character
\r, \n, \t, \f, \v Respective escaped characters
\xxx Octal character specified by xxx
\xdd Hexadecimal character specified by xx
\uxxxx Unicode character specified by xxxx

 

Share!

Advertisements