#!/usr/local/bin/ruby -w
def show_regexp(a,re)
if a =~ re
"#{$`}<<#{$&}>>#{$'}"
else
"no match"
end
end
puts show_regexp('very interesting',/t/)
puts show_regexp('Fats Waller',/a/)
转载于:https://my.oschina.net/7shell/blog/381715
#!/usr/local/bin/ruby -w
def show_regexp(a,re)
if a =~ re
"#{$`}<<#{$&}>>#{$'}"
else
"no match"
end
end
puts show_regexp('very interesting',/t/)
puts show_regexp('Fats Waller',/a/)
转载于:https://my.oschina.net/7shell/blog/381715