From: Dave Thomas Date: 2002-02-07T05:55:29+09:00 Subject: Re: Regexp::Parser ported to Ruby...? Tobias Reif writes: > > In Perl, you can execute arbitrary code in a regex. > > > > "japhy" =~ /((.)(?{ print "<$2>" }))+/; > > #

> > > > I guess that's not possible in Ruby? > > > One way: > > irb(main):003:0> "japhy".gsub(/./)do print "<#{$&}>" end >

"" Or "japhy".scan(/./) { |ch| print "<#{ch}>" }