Re: Need help with a match

2017-03-13 Thread Richard Hainsworth
Seems to me because the second '(' is not preceded by a space; it is '`('. But if the second '(' was eg '` (', then the longest match would have been picked and a ? would be necessary. On Tuesday, March 14, 2017 11:21 AM, ToddAndMargo wrote: On 03/13/2017 08:16 PM, ToddAndMargo wrote: On

Re: Need help with a match

2017-03-13 Thread ToddAndMargo
On 03/13/2017 08:16 PM, ToddAndMargo wrote: On 03/13/2017 07:53 PM, yary wrote: I think p6 regexes behave a bit like p5 regexes with the "x" flag turned on, where whitespace can be added in for readability. To have literal whitespace, put quotes around it. Like this (untested) $x ~~ m/sub ' '

Re: Need help with a match

2017-03-13 Thread ToddAndMargo
On 03/13/2017 07:53 PM, yary wrote: I think p6 regexes behave a bit like p5 regexes with the "x" flag turned on, where whitespace can be added in for readability. To have literal whitespace, put quotes around it. Like this (untested) $x ~~ m/sub ' ' (.*) ' ' \(/; Now that was way to easy

Re: Need help with a match

2017-03-13 Thread ToddAndMargo
On 03/13/2017 07:58 PM, Brandon Allbery wrote: There is actually a third issue in that spaces are *ignored* in regexes, so you actually end up with $/[0] eq ' Test'. Use the <.ws> rule to avoid this. (The leading dot prevents that whitespace from additionally being captured as $/ which here

Re: Need help with a match

2017-03-13 Thread Brandon Allbery
There is actually a third issue in that spaces are *ignored* in regexes, so you actually end up with $/[0] eq ' Test'. Use the <.ws> rule to avoid this. (The leading dot prevents that whitespace from additionally being captured as $/ which here would be pointless. You might also want one before

Re: Need help with a match

2017-03-13 Thread yary
I think p6 regexes behave a bit like p5 regexes with the "x" flag turned on, where whitespace can be added in for readability. To have literal whitespace, put quotes around it. Like this (untested) $x ~~ m/sub ' ' (.*) ' ' \(/;

Re: Need help with a match

2017-03-13 Thread Brandon Allbery
You have two problems: (1) matches start from 0, not 1. (2) .* gobbles as much as possible (this is also true in Perl 5) so it matches to the ) at the end of (Sub|63218616). As in Perl 5, you add a ? to make it take the shortest match instead: #!/usr/bin/perl6 my $x='sub Test () {

Need help with a match

2017-03-13 Thread ToddAndMargo
Hi All, Just as soon as I think I understand it, a little humility fall into my lap! #!/usr/bin/perl6 my $x='sub Test () { #`(Sub|63218616) ... }'; $x ~~ m/sub (.*) \(/; say "$x\n$1"; $ WhoTest2.pl6 Use of Nil in string context in block at ./WhoTest2.pl6 line 4 sub Test () {