Using the *, + and ? symbols
the symbols '*', '+', and '?', denote the number of times a character or a sequence of characters may occur.
What they mean is:
* = "zero or more"
+ = "one or more"
? = "zero or one."
eg
/ab*/ : would match a string that has an a followed by zero or more b's ("ac", "abc", "abbc", etc.)
/ab+/ : same, but there's at least one b ("abc", "abbc", etc., but not "ac")
/ab?/ : there might be a single b or not ("ac", "abc" but not "abbc").
/a?b+$/ : a possible 'a' followed by one or more 'b's at the end of the string:
Matches any string ending with "ab", "abb", "abbb" etc. or "b", "bb" etc. but not "aab", "aabb" etc.
Using the braces { } symbol
Known as bounds...values which appear inside braces indicate ranges in the number of occurrences
Note... that you must always specify the first number of a range (i.e., "{0,2}", not "{,2}").
Also, the symbols '*', '+', and '?' have the same effect as using the bounds "{0,}", "{1,}", and "{0,1}", respectively.
eg
/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 two or more b's ("abb", "abbb" etc)
/ab{3,5}/ : matches a string that has an a followed by three to five b's ("abbb", "abbbb" or "abbbbb")
Using the round brackets ( ) symbols (parentheses)
To quantify a sequence of characters, put them inside parentheses
eg
/a(bc)*/ : matches a string that has an a followed by zero or more copies of the sequence "bc"
/a(bc){1-5}/ : same, but there must be between one and five instances of the sequence "bc")
Using the | symbol
Known as the OR operator...
eg
/hi|hello/ : matches a string that has either "hi" or "hello" in it
/(b|cd)ef)/ : matches "bef" or "cdef"
Using the dot (.) symbol
A dot (.) stands for any single character
eg
/a.[0-9]/ : matches a string that has an 'a' followed by any chr and a digit (0-9)
/^.{3}$)/ : matches a string with exactly 3 chr's in it