Y
Yvon Thoraval
I'm doing some experiment using the "rubyguide" giving this script :
#!/usr/bin/ruby
# regex.rb
# Requires an ANSI terminal!
st = "\033[7m"
en = "\033[m"
while TRUE
print "str> "
STDOUT.flush
str = gets
break if not str
str.chop!
print "pat> "
STDOUT.flush
re = gets
break if not re
re.chop!
str.gsub! re, "#{st}\\&#{en}"
print str, "\n"
end
print "\n"
when trying it i get the following warning :
pp:~/Applications/Ruby/Tutorial> ruby regex.rb
str> foobar
pat> ^fo+
regex.rb:19: warning: string pattern instead of regexp; metacharacters
no longer effective
foobar
str> abc012dbcd555
pat> \d
regex.rb:19: warning: string pattern instead of regexp; metacharacters
no longer effective
abc012dbcd555
does that means my term isn't an ANSI one or the syntax as changed ?
tuto is mostly from v 1.4 and i'm using v1.8 under MacOS X.2.6
#!/usr/bin/ruby
# regex.rb
# Requires an ANSI terminal!
st = "\033[7m"
en = "\033[m"
while TRUE
print "str> "
STDOUT.flush
str = gets
break if not str
str.chop!
print "pat> "
STDOUT.flush
re = gets
break if not re
re.chop!
str.gsub! re, "#{st}\\&#{en}"
print str, "\n"
end
print "\n"
when trying it i get the following warning :
pp:~/Applications/Ruby/Tutorial> ruby regex.rb
str> foobar
pat> ^fo+
regex.rb:19: warning: string pattern instead of regexp; metacharacters
no longer effective
foobar
str> abc012dbcd555
pat> \d
regex.rb:19: warning: string pattern instead of regexp; metacharacters
no longer effective
abc012dbcd555
does that means my term isn't an ANSI one or the syntax as changed ?
tuto is mostly from v 1.4 and i'm using v1.8 under MacOS X.2.6