Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: f958381438
Fetching contributors…

Cannot retrieve contributors at this time

executable file 31 lines (25 sloc) 0.984 kb
#!/usr/local/bin/perl6
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 replace_x($s is copy) {
while defined (my $start = $s.index("\\x")) {
my $end = $start + 2;
++$end while $s.substr($end, 1) ~~ /<[0..9a..fA..F]>/;
my $n = $s.substr($start + 2, $end - $start - 2);
$s = $s.substr(0, $start) ~ chr(:16($n)) ~ $s.substr($end);
}
$s
}
sub backslash_escape($string) {
# RAKUDO: No .trans again yet
#return $string.trans(['\n', '\r', '\e', '\t', '\f'] =>
# ["\n", "\r", "\e", "\t", "\f"])\
return replace_x $string.subst(/\\n/, "\n", :g).subst(/\\r/, "\r", :g).subst(/\\e/, "\e", :g).subst(/\\t/, "\t", :g).subst(/\\f/, "\f", :g);
}
Jump to Line
Something went wrong with that request. Please try again.