-
-
Save kanatohodets/d5161b57b43b3f2837a0 to your computer and use it in GitHub Desktop.
Difference in regex between grammar tokens and m//?
This file contains 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
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