Sebastian Hungerecker
9/30/2007 8:46:00 AM
Filipe wrote:
> def showRE(a,re)
> #re = Regexp.new(re) if re.class==String
> #re=Regexp.new(re.to_s) if re.class==Integer
> if a=~re
> "#{$`}<<#{$&}>>#{$'}"
> else
> "no match"
> end
> end
>
> puts showRE("Hello", /(\w)\1/) #=> no match
> puts showRE("Hello", /(\w{1,1})\1/) #=> He<<ll>>o
Both return "He<<ll>>o" for me.
ruby 1.8.6 (2007-09-23 patchlevel 110) [x86_64-linux]
--
Jabber: sepp2k@jabber.org
ICQ: 205544826