Learn to use regular expressions by following RegexTip. From @JohnDCook.

Joined November 2009
68 Photos and videos
Pinned Tweet
Four tips for learning regular expressions bit.ly/Xn7UH

6
109
222
(?i) makes a regular expression case-insensitive. Example: (?i)abc is the same as [aA][bB][cC].
6
888
In CSS, ^= means begins with, *= means contains anywhere, and $= means ends with.
6
862
CSS has a crude form of regex, selection operators ^=, *=, and $= analogous to the use of ^, *, and $ in regex.
7
846
The acronym PCRE stands for 'Perl Compatible Regular Expressions'.
7
1,034
*?, ?, and ?? are lazy quantifiers. The regexp engine will attempt to match as few tokens as possible.
1
3
920
In Perl, \A matches the beginning of a string and \z matches the end of a string. Removes ambiguity of lines vs strings.
1
3
1,014
Emacs regex escape |, (, and ). For example, (a|b) in Perl becomes \(a\|b\) in Emacs.
4
1,055
To group without capturing, use (?: ... ).
7
1,114
“Regular expressions aren’t random jumbles of punctuation—they’re carefully thought-out jumbles of punctuation!” -- The Perl Cookbook
3
11
950
\> represents an ending word boundary and match a position between two tokens. Some engines don't support this.
3
716
\< represents a beginning word boundary and match a position between two tokens. Some engines don't support this.
3
859
\b matches a word boundary; \B matches anything but a word boundary.
5
1,151
Don't confuse \1 with $1. \1 is used inside a regex; $1 (in Perl) is used outside the regex after a match.
2
1,193
Many languages support Perl 5 regular expressions. For example, Microsoft .NET supports Perl 5 regex with some of its own extensions.
1
3
1,048
\d represents the numerical characters, or [0123456789]. Its complement is \D.
5
1,104