#!/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/)
ruby regular Expressions
原文:http://my.oschina.net/7shell/blog/381715