/ Published in: Ruby
don't forget to include parentheses around the expressions you want to match
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
str = "Q1-1947" str =~ /Q(\d)-(\d{4})/ # prints "1" puts $1 # prints "1947" puts $2
URL: http://www.regular-expressions.info/ruby.html