develooper Front page | perl.perl6.users | Postings from April 2020

subst :g and captures in the replacement

Thread Next
From:
yary
Date:
April 19, 2020 21:54
Subject:
subst :g and captures in the replacement
Message ID:
CAG2CFAbzNGFM_L4ChOb8V4sCmtGt13kjvgns9SPnKfGV3xp3hg@mail.gmail.com
Question from today's Raku meetup. This works in a way I expect

> 'fosdffgg'.subst(/f+/,"( "~ * ~" )", :g);
( f )osd( ff )gg

This one, $0 gets the single f each time

> 'fosdffgg'.subst(/(f+)/,"( $0 )", :g);
( f )osd( f )gg

Bug or misunderstanding on my part?

-y

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About