Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 20 lines (15 sloc) 561 Bytes
#!/usr/bin/alpha
use v6;
use GGE;
die "Usage: ./test-regex <pattern> <target>"
unless @*ARGS == 2;
my ($pattern, $target) = @*ARGS;
my GGE::Match $match
= GGE::Perl6Regex.new($pattern, :debug)\
.( backslash_escape($target), :debug );
say $match ?? $match.dump_str('mob', ' ', '') !! "No match\n";
sub backslash_escape($string) {
return $string.trans(['\n', '\r', '\e', '\t', '\f'] =>
["\n", "\r", "\e", "\t", "\f"])\
.subst(/'\\x' (<[0..9a..f]>**{4})/, { chr(:16($0)) }, :g);
}