Regular Expression Description Example
. Matches any single character (“..”, “a%”) – true(“..”, “.a”) – true
(“..”, “a”) – false
^xxx Matches xxx regex at the beginning of the line (“^a.c.”, “abcd”) – true
(“^a”, “ac”) – false
xxx$ Matches regex xxx at the end of the line (“..cd$”, “abcd”) – true(“a$”, “a”) – true
(“a$”, “aca”) – false
[abc] Can match any of the letter a, b or c. [] are known as character classes.
(“^[abc]d.”, “ad9″) – true(“[ab].d$”, “bad”) – true
(“[ab]x”, “cx”) – false
[abc][12] Can match a, b or c followed by 1 or 2
(“[ab][12].”, “a2#”) – true(“[ab]..[12]“, “acd2″) – true
(“[ab][12]“, “c2″) – false
[^abc] When ^ is the first character in [], it negates the pattern,
matches anything except a, b or c
(“[^ab][^12].”, “c3#”) – true(“[^ab]..[^12]“, “xcd3″) – true
(“[^ab][^12]“, “c2″) – false
[a-e1-8] Matches ranges between a to e or 1 to 8
(“[a-e1-3].”, “d#”) – true(“[a-e1-3]“, “2″) – true
(“[a-e1-3]“, “f2″) – false
xx|yy Matches regex xx or yy (“x.|y”, “xa”) – true(“x.|y”, “y”) – true
(“x.|y”, “yz”) – false