Skip to content

Instantly share code, notes, and snippets.

@kanatohodets
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanatohodets/d5161b57b43b3f2837a0 to your computer and use it in GitHub Desktop.
Save kanatohodets/d5161b57b43b3f2837a0 to your computer and use it in GitHub Desktop.
Difference in regex between grammar tokens and m//?
my $line = '137.22.189.191 - - [02/Feb/2014:23:37:36 -0600] "GET / HTTP/1.1" 200 669 ... blah blah';
grammar FooParser {
rule TOP {<date>}
token date {\[$<date> = [<-[\]]>+?]\]}
}
say $line ~~ m/\[$<date> = [<-[\]]>+?]\]/;
say FooParser.parse($line);
#output:
#「[02/Feb/2014:23:37:36 -0600]」
# 0 => 「02/Feb/2014:23:37:36 -0600」
##<failed match>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment