To Documents

Some Regular Expression Tokens

Token Meaning   Token Meaning
/ Start and end of Ruby regular expression   \ / Literal /
^ Start of line   \^ Literal ^
$ End of line   \$ Literal $
\A Start of string   A Literal A
\Z End of string   Z Literal Z
\b Word boundary   b Literal b
\B Non-word boundary   B Literal B
[a-z] Any lower case letter      
[A-Z] Any upper case letter      
[^a-z] Any non-lower case letter      
[^A-Z] Any non-upper case letter      
\d Any digit; same as [0-9]   d Literal d
\D Any non-digit; same as [^0-9]   D Literal D
\w Any word character; same as [A-Za-z0-9]   w Literal w
\W Any non-word character; same as [^A-Za-z0-9]   W Literal W
\s Any whitespace character; same as [ \n\r\f\t\v]   s Literal s
\S Any non-whitespace character; same as [^ \n\r\f\t\v]   S Literal S.
(  ) Grouping   \(  \) Literal (  )
| Or      
. Any character   \. Literal .
? 0 or 1 occurrencess   \? Literal ?
* 0 or more occurrencess   \* Literal *
+ 1 or more occurrences   \+ Literal +
{n} Exactly n occurrences   \{ Literal {
{n,m} Between n and m occurrences   \} Literal }