From: Vince Forgetta Date: 2004-04-14T22:47:36+09:00 Subject: Re: embedded code construct a la perl I want to find all nested pattern matches in a string, and execute some code at each match. This should include searching all nested substrings of a match. I realize I could do this in perl ( I have been up to now), but my code is getting quite complex and I would like to implement an object model (something I could also do in perl, but works much better in Ruby). In perl, I was able to do this in a regexp (example below). Can I do the same thing in ruby, or will I need to use some sort of loop to wun code at each match. Thanks. Vince Robert Klemme wrote: >"Vince Forgetta" schrieb im Newsbeitrag >news:407C1AD7.3040406@staff.mcgill.ca... > > >>Hi all, >> >>Is it possible to use embedded-code constructs in ruby regexp? >> >>Perl Example: >> >> >> >>"123"= ~ m{ >> >> > >I guess, this should have read >"123" =~ m{ > > > >>\d+ >>(?{print "matched at [$'<$&>$']\n"}) >>(?!) >>}x; >> >> >> >>Output: >> >>matched at [<123>] >>matched at [<12>3] >>matched at [<1>23] >>matched at [1<23>] >>matched at [1<2>3] >>matched at [12<3>] >> >> > >No. If you let us know what you want to do mayve we can come up with an >alternative solution. > >Regards > > robert > > > > > > -- Vincenzo Forgetta Computational Biology McGill University and Genome Quebec Innovation Centre 740 Dr. Penfield Avenue Room 7211 Montreal, Quebec Canada, H3A 1A4 Tel: 514-398-3311 00476 Email: vince.forgetta@staff.mcgill.ca