Created
February 13, 2013 16:19
-
-
Save jnthn/4945749 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use QRegexJVM; | |
sub try_match($s) { | |
# Create a cursor. | |
my $ci := NQPCursor.'!cursor_init'($s); | |
# Start it, match a digit. | |
my $c := $ci.'!cursor_start_cur'(); | |
$c.'!cursor_pos'(0); | |
my $d := $c.digit(); | |
# Get the Match object; boolify. | |
my $m := $d.MATCH(); | |
$m.Bool() | |
} | |
say(try_match('5')); # 1 | |
say(try_match('a')); # 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment