/pattern/--
pattern除了   .    |     (      )      [         ]        {         }    +     \       ^       $      *    ?
这14个字符之外,所有字符均匹配它们本身
如果要匹配这14个字符,要在这些字符前面加反斜线\
锚点anchor:      锚点检查开头结尾
默认情况下,RegExp会试图发现模式在字符串中出现的第一个匹配。对于Mississippi字符串匹配/iss/,它会找出从位置1开始的"iss"子字符串。如果想强迫模式只匹配字符串的开始或结束部分呢?
^和$模式分别匹配行首和行尾。锚定模式匹配:
\A序列匹配字符串的开始位置\z和\Z匹配字符串的结尾位置(实际上,除非字符串以\n结束,\Z才会匹配字符串的结尾)
正则表达式2  模式_休闲puts show_regexp("this is \nthe time", /^the/)
正则表达式2  模式_休闲puts show_regexp("this is\nthe time", /is$/)
正则表达式2  模式_休闲puts show_regexp("this is the time\n", /time\z/)
正则表达式2  模式_休闲puts show_regexp("this is the time\n", /time\Z/)
正则表达式2  模式_休闲puts show_regexp("this is the time", /time\z/)
1.this is
<<the>> time
2.this <<is>>
the time
3.no match
4.this is the <<time>>
5.this is the <<time>>
#----^是从字符串开始或者紧跟在\n之后的字符串开始匹配,$,\z,\Z从结尾开始匹配,不同的是:$从\n之前紧跟的字符匹配
 
字符类
字符类是处于方括号[]之间的字符集合:[characters]匹配方括号内的任何单个字符,[aeiou]会匹配原音,[,.:;!?]匹配括号内的标点符号
例:
show_regexp('Price $12.')