In Edit distance: Ignore start/end, I offered a Perl 6 solution to a fuzzy fuzzy matching problem. I had a grammar like this (although maybe I've improved it after Edit #3):
grammar NString {
regex n-chars { [<.ignore>* \w]**4 }
regex ignore { \s }
}
The literal 4
itself was the length of the target string in the example. But the next problem might be some other length. So how can I tell the grammar how long I want that match to be?
Although the docs don't show an example or using the
$args
parameter, I found one in S05-grammar/example.t in roast.Specify the arguments in
:args
and give the regex an appropriate signature. Inside the regex, access the arguments in a code block:I'm still not sure about the rules for passing the arguments though. This doesn't work:
I get:
This works:
But that's enough thinking about this for one night.