Created
May 12, 2011 15:45
-
-
Save shingonoide/968791 to your computer and use it in GitHub Desktop.
Irb session testing generic regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby-1.8.7-p334 :001 > /<p>.*</p>/ | |
ruby-1.8.7-p334 :002/> /<p>.*<\/p>/ | |
SyntaxError: compile error | |
(irb):1: unknown regexp option - p | |
(irb):2: syntax error, unexpected '.' | |
/<p>.*<\/p>/ | |
^ | |
from (irb):2 | |
ruby-1.8.7-p334 :003 > /<p>.*<\/p>/ | |
=> /<p>.*<\/p>/ | |
ruby-1.8.7-p334 :004 > r = /<p>.*<\/p>/ | |
=> /<p>.*<\/p>/ | |
ruby-1.8.7-p334 :005 > r | |
=> /<p>.*<\/p>/ | |
ruby-1.8.7-p334 :006 > r.match | |
ArgumentError: wrong number of arguments (0 for 1) | |
from (irb):6:in `match' | |
from (irb):6 | |
ruby-1.8.7-p334 :007 > texto = '<p>blablabla</p>' | |
=> "<p>blablabla</p>" | |
ruby-1.8.7-p334 :008 > r.match texto | |
=> #<MatchData "<p>blablabla</p>"> | |
ruby-1.8.7-p334 :009 > r = /<p>(.*)<\/p>/ | |
=> /<p>(.*)<\/p>/ | |
ruby-1.8.7-p334 :010 > r.match texto | |
=> #<MatchData "<p>blablabla</p>" 1:"blablabla"> | |
ruby-1.8.7-p334 :011 > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment