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

To include a literal ^ in a character class, don't put it first: /[^^]/ matches any char except '^'.
1
2
11
2,427
? means a character or expression is optional, i.e. zero or one occurrences. Example: /ab?c/ matches 'ac' and 'abc' but not 'abbc'.
7
2,362
* means zero or more occurrences. Ex: /ab*c/ matches 'ac', 'abc', 'abbc', etc.
11
2,343
Languages have minor variations in their regex support. @RegexTip mostly sticks to the common features of Perl, C#, Python, JavaScript, ...
9
2,322
Regex matches are usually not anchored. If you forget ^ and $, your pattern can match inside a larger string unexpectedly.
1
10
2,490
Unicode Regular Expressions Standard: unicode.org/reports/tr18/
9
2,328
A hyphen is a range marker only *inside* a character class and not at the edges. /[a-z-]/ matches letters or '-'; /[a-z]/ is just letters.
10
2,439
Prefer using libraries for phone numbers, URLs, emails, etc. when quick-and-dirty isn't good enough correctness matters.
6
2,468
Create a diagram of a regular expression regexper.com/
6
2,420
Performance tip: if you can, start your pattern with a literal prefix. Engines can skip quickly to the prefix before doing heavier work.
1
15
2,470
Escaping is context-dependent. Outside [...], '.' is special; inside a character class, [.] is just a period. Can be clearer than \.
2
2,361
Use a non-capturing group when you don't need backreferences: /(?:cat|dog)s?/ matches 'cat', 'cats', 'dog', 'dogs' without creating a capture group.
5
2,377
'Everybody stand back. I know regular expressions.' xkcd.com/208/
1
18
3,303
Regular expressions in Haskell wiki.haskell.org/Regular_exp…
3
2,458
Properties such as \p{Alphabetic} can be easier to read than [A-Za-z]. Works better with internationalization as well.
1
1
15
2,672
Adding a + after a quantifier tells it to not give anything back when the regex engine backtracks.
1
2
2,429