/ Published in: Ruby

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# pass a Regexp into a String as if it were an Array index "cat"[/c/] #=> "c" "cat"[/z/] #=> nil # pass in an optional second argument, to return the content of the nth matching group re_phone = /(\d{3})-(\d{3})-(\d{4})/ "986-235-1001"[re_phone, 2] #=> "235"
URL: http://whytheluckystiff.net/articles/rubyOneEightOh.html
Comments
