| Category: | Perl 6 |
| Author/Contact Info | Brent Dax (brentdax@cpan.org) |
| Description: | This one is straight out of the documentation included with Parrot's regex library. I'm copying-and-pasting it here only because I wrote the library and the docs. :^) If you're curious to see how this is constructed, take a look at the documentation in the Parrot distribution's rx.ops file. |
# NOTE: This looks a LOT scarier than it really is
# "zzabbBBBBBBcdcdcdzz" =~ /ab*[cd]+/i
rx_allocinfo P0, "zzabbBBBBBBcdcdcdzz"
bsr RX_0
rx_info_successful P0, I0
rx_freeinfo P0
if I0, $match
print "no "
$match:
print "match"
end
RX_0:
rx_setprops P0, "i", 2
branch $start0
$advance:
rx_advance P0, $fail
$start0:
rx_literal P0, "a", $advance
$start1:
rx_pushmark P0
$top1:
rx_literal P0, "b", $start2
rx_pushindex P0
branch $top1
$back1:
rx_popindex P0, $advance
$start2:
rx_literal P0, "cd", $back1
$top2:
rx_oneof P0, "cd", $succeed
branch $top2
$succeed:
rx_succeed P0
ret
$fail:
rx_fail P0
ret
|
|
|
|---|