Created
December 9, 2014 15:03
-
-
Save tSU-RooT/711a04d9d26364d5fd26 to your computer and use it in GitHub Desktop.
Check_Regexp
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
# coding: utf-8 | |
print "check_regexp on Ruby\n" | |
print "正規表現の入力が終わったらSTARTと入力してください。\n" | |
print ">" | |
patterns = [] | |
while str = STDIN.gets | |
str.chomp! | |
break if str == "START" | |
patterns.push(Regexp.new(str)) | |
print ">" | |
end | |
print "Check Your Inputs!\n" | |
print "チェックが終了したらQUITと入力してください。\n" | |
print ">" | |
while str = STDIN.gets | |
str.chomp! | |
break if str == "QUIT" | |
for p in patterns | |
match_data = p.match(str, 0); | |
if match_data != nil | |
print "true\n" | |
if match_data.size > 1 | |
for i in 1...match_data.size | |
print "#{i}:#{match_data[i]}\n" | |
end | |
end | |
else | |
print "false\n" | |
end | |
end | |
print ">" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment