REGULAR EXPRESSIONS
-------------------

Regular expressions are placed between a pair of forward slashes:
/abba/


---------------------The Basics (example) ---------------------

abba				matches the first occurence of this four character string in the line "yabba dabba do".




---------Metacharacters (special characters)---------

.					matches any single character except newline

\					used to escape special characters

\\					use two backslashes to indicate a real backslash

*					match the preceding item (except newline) zero or more times

+					match the preceding item (except newline) one or more times

.*					matches anything, any length (except newline)

?					match the preceding item (except newline) zero or one times only

/a{5,15}/				match only five to fifteen repetitions of the letter a


/a{5,15}/				match five or more repetitions of the letter a


/a{5}/					match exactly five repetitions of the letter a


/\w{8}/				match exactly eight word characters 


/(fred)+/				matches the pattern "fred" one or more times


/fred|barney|betty/			matches fred or barney or betty


/fred( |\t)+barney/			matches fred and barney separated by one or more spaces or tabs or a mixture
					of both

/fred( +|\t+)barney/			matches fred and barney separated by one or more spaces or tabs but not
					a mixture of both



---------CHARACTER CLASS SHORTCUTS---------

/CA[A-P]/				matches CA followed by a single character in the character class A to P.  CAB
					will match, CAR will not.

/CA[^A-P]/				matches CA followed by a single character NOT in the character class A to P.
					CAB will not match but CAR will.

/[0-9]/ 				same as		/[\d]/


/[A-Za-z0-9]/				same as		/[\w]/	(also includes underscores)


/[\s]/					same as		/[\f\t\n\r ]/	(form-feed, tab, newline, return and space)


/[^\d]/				same as		/^[0-9]/	matches anything except 0 - 9


/[^\w]/				same as		/[^A-Za-z0-9]/	matches anything except numbers, letters
					and underscores

/[^\s]/				same as		/[^\f\t\n\r ]/	matches anything except whitespace characters.


/[\dA-Fa-f]+/				matches hexadecimal numbers


/[\d\D]/				matches any character including newline


/[^\d\D]/				matches nothing


/^fred/				match fred only at the start of the string


/rock$/				match rock only at the end of the string (or at a newline at the end of the string)


/^\s*$/				match any blank line including those with whitespace (form-feed, tab, newline, etc.)


/\bfred\b/ 				matches the word fred but not frederick or alfred or manfred mann


/\bhunt/				match words like hunt or hunting or hunter, but not shunt.


/stone\b/				match words like sandstone or flintstone but not capstones.


/\bsearch\B/				matches at any point where \b would not match. Matches searches, searching, and searched
					but not search, research or researching.

/(.)\1/				match any character followed by the same character (memory parenthesis)


/((go|stop) (team|car)) \1/ 	matches "go team go team" or "stop team stop team" or "go car go car"


/((go|stop) (team|car)) \2/ 	matches "go team go" or "stop team stop" or "stop car stop"


/((go|stop) (team|car)) \3/ 	matches "go team team" or "stop team team" or "go car car"




---------Operator Precedence---------

Parentheses 				( ) 

Quantifiers 				asterisk (*), plus (+), question mark (?), curly braces {5,15}, {3,}, and {5}

Anchors and sequence			caret (^), dollar-sign ($), the \b word-boundary anchor, the \B nonword-boundary anchor 

Vertical bar				(|)