Created
January 21, 2012 02:50
-
-
Save abinoam/1650955 to your computer and use it in GitHub Desktop.
Testing for a possible regexp bug on 1.9.2-290
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
#!/usr/bin/env ruby | |
regexp = /^([A-Z]{1,4})([0-9]{1,4})$/ | |
text_phrases = | |
[ "ABCD1234", | |
"ABCDE1234", | |
"ABCD12345", | |
"ABCDE12345"] | |
puts RUBY_DESCRIPTION | |
text_phrases.each do |tp| | |
match = tp.match regexp | |
if match | |
puts "#{tp} matches #{regexp.inspect} capturing: #{match.captures}" | |
else | |
puts "#{tp} doesn't match #{regexp.inspect}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, ran in irb (am Windows) and got below (expected results)
As per http://www.ruby-forum.com/topic/3476712#1041898 when running from Windows cmd it turns out swapping double/single quotes around gave expected behaviour.
ABCD1234 matches /^([A-Z]{1,4})([0-9]{1,4})$/ capturing: ["ABCD", "1234"]
ABCDE1234 doesn't match /^([A-Z]{1,4})([0-9]{1,4})$/
ABCD12345 doesn't match /^([A-Z]{1,4})([0-9]{1,4})$/
ABCDE12345 doesn't match /^([A-Z]{1,4})([0-9]{1,4})$/