#!/usr/bin/ruby
pre = "\033[7m"
post = "\033[m"
print "Cadena> "
STDOUT.flush
str = gets.chop!
while true
print "Expresion regular> "
STDOUT.flush
re = Regexp.new(gets.chop!)
puts str.gsub(re, "#{pre}\\&#{post}")
end
Un ejemplo de uso.

Blog de programación y diseño de software
#!/usr/bin/ruby
pre = "\033[7m"
post = "\033[m"
print "Cadena> "
STDOUT.flush
str = gets.chop!
while true
print "Expresion regular> "
STDOUT.flush
re = Regexp.new(gets.chop!)
puts str.gsub(re, "#{pre}\\&#{post}")
end
0 comentarios:
Publicar un comentario