use / / to include regular expression
ex:
/a/
test regular expression match:
use =~
ex:
“hello”=~ /el?/
---> 1
? :
zero or more occurrence
+:
one or more occurrence
\W:
any whitespace
\{X}:
ex:
a{3}
--> three a
\d:
any digit
\:
treat the special character after it as normal character
^ :
anchor for the beginning of a line
$:
anchor for the end of a line
*:
match 0 or more occurrences of preceding character
Regexp.new:
ex:
Regexp.new("test")
---> /test/
沒有留言:
張貼留言