You are on page 1of 2

^Amazon matches any string that starts with "Amazon".

google$ matches a string that ends with "google".


matches a string that starts and ends with "abc" - effectively an exact match
^abc$
comparison.
notice matches a string that has the text "notice" in it.

^((?!output).)*$ matches any string that does not contain "output" or any case insensitive variation.
Matches any string that does does not start with "output" or any case insensitive
^(?!output).*$
variation.
.*(?<!output)$ Matches any string that does not end with "output" or any case insensitive variation.
^(?!output$).* Matches any string that is not exactly "output" or any case insensitive variation.

.at matches any three-character string ending with "at", including "hat", "cat", and "bat".
[hc]at matches "hat" and "cat".
[^b]at matches all strings matched by .at except "bat".
[^hc]at matches all strings matched by .at other than "hat" and "cat".
^[hc]at matches "hat" and "cat", but only at the beginning of the string or line.
[hc]at$ matches "hat" and "cat", but only at the end of the string or line.
matches any single character surrounded by "[" and "]" since the brackets are escaped,
\[.\]
for example: "[a]" and "[b]".
s.* matches any number of characters preceded by s, for example: "saw" and "seed".

[hc]+at matches "hat", "cat", "hhat", "chat", "hcat", "cchchat", and so on, but not "at".
[hc]?at matches "hat", "cat", and "at".
[hc]*at matches "hat", "cat", "hhat", "chat", "hcat", "cchchat", "at", and so on.
cat|dog matches "cat" or "dog".

ab{2} matches a string that has an "a" followed by exactly two b's ("abb")
ab{2,} matches a string that has an "a" followed by at least two b's ("abb", "abbbb", etc.)
matches a string that has an "a" followed by three to five b's ("abbb", "abbbb", or
ab{3,5}
"abbbbb")
hi|hello matches a string that has either "hi" or "hello" in it
(b|cd)ef matches a string that has either "bef" or "cdef"
(a|b)*c matches a string that has a sequence of alternating a's and b's ending in a c

[ab] matches a string that has either an a or a b (that's the same as "a|b")
matches a string that has lowercase letters 'a' through 'd' (that's equal to "a|b|c|d" and
[a-d]
even "[abcd]")
^[a-zA-Z] matches a string that starts with a letter
[0-9]% matches a string that has a single digit before a percent sign
,[a-zA-Z0- 9]$ matches a string that ends in a comma followed by an alphanumeric character

You might also like