Designation: Non-Finmeccanica Tobias Leich,
To count substitutions with s;g///; I use: $n = 0; s:g/..../....{"" if ++$n}/; Thank you for your help; all resolved. Peter Schwenn -----Original Message----- From: Schwenn, Peter Sent: Monday, May 05, 2014 12:24 PM To: 'perl6-bugs-follo...@perl.org' Subject: RE: [perl #121798] m:ov and m:ex multiple regex matches not working Designation: Non-Finmeccanica Dear Tobias Leich, That works fine and is more accurate than the work around (based on split() ) that I had been using. Thank you, ----------------------------------------------------------------------------------------------------------------------------------------------------------------- I have discovered a way to count multiple matches using s:g///; only, namely: my $n=0; $layn ~~ s:g/pattern/substitution{$n++}/; But I don't know how to keep the value of {$n++} out of the substitutions. Thank you, Peter Schwenn -----Original Message----- From: Tobias Leich via RT [mailto:perl6-bugs-follo...@perl.org] Sent: Monday, May 05, 2014 2:57 AM To: Schwenn, Peter Subject: Re: [perl #121798] m:ov and m:ex multiple regex matches not working Am 04.05.2014 23:22, schrieb schw...@rt.perl.org: > # New Ticket Created by Schwenn, Peter # Please include the string: > [perl #121798] # in the subject line of all future correspondence > about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=121798 > > > > Dear Perl6'ers, > > I am using 2014.3 Star’s MSI to build a production translator (updating about > 1000 C# source files to be compatible with new libraries). > > I have successfully written a mass of substitutions based on the s/// form. > > Now I'm trying to count the matches that have been made, so because one can't > count s:g/// matches (apparently), I'm pairing an m:ex/.../ {say ... } with > each s:g///;, using the same matching pattern. > > But " ~~ m:ov/.../" and "m:ex/.../" and "ms:g/.../" all seem to be > broken in the sense that they won't even find multiple matches (or if > they do they won't store or report them according to S05.) > > For example, > >> say "abracadabra" ~~ m:ov/a+/ > False > >> say "abracadabra" ~~ m:ex/a(.*)a/ > False > > and nothing is ever reported by > if $str ~~ m:ex/.../ {say [$/];} > same for m:ov/..., > same for ms:g/..., > and same for using @() instead of [$/] > > In fact no example from S05 that deals with reporting or storing multiple > matches with "~~ m.../" works. > > (Single match m/.../ seems to work fine AND report the number of > matches i.e. 0 or 1) by either +[$/] or +@() ) > > [In short I am looking for any way of reporting multiple matches.] > > Thank you, > > Peter Schwenn > > > Hi, it seems like the method form works where the m// does not... <FROGGS> m: say "abracadabra" ~~ m:g/a+/ <camelia> rakudo-moar fd5f8e: OUTPUT«False» <FROGGS> m: my $m = "abracadabra".match(/a+/, :g); say $m; say $m.elems <camelia> rakudo-moar fd5f8e: OUTPUT«「a」 「a」 「a」 「a」 「a」5» Does that help you here? Cheers, FROGGS 3.3.042312 3.3.042312