Skip to content

Instantly share code, notes, and snippets.

@guilherme
Created March 6, 2012 20:13
Show Gist options
  • Save guilherme/1988720 to your computer and use it in GitHub Desktop.
Save guilherme/1988720 to your computer and use it in GitHub Desktop.
Regexp ruby
1.9.2p290 :013 > "abcd test 123".match(/(?<title>([\p{Word} ]*))((?<test>test 123)|(?<test>123))/)
=> #<MatchData "abcd test 123" title:"abcd test " test:nil test:"123">
# REGEXP Y U NO MATCH THE ENTIRE STRING (test 123) ?
1.9.2p290 :018 > "abcd test 123".match(/([\p{Word} ]*)(test 123|123)/)
=> #<MatchData "abcd test 123" 1:"abcd test " 2:"123">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment