Published in: Ruby
URL: http://whytheluckystiff.net/articles/rubyOneEightOh.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"
You need to login to post a comment.
