Re: need s/ help

2018-05-01 Thread ToddAndMargo
On 05/01/2018 05:19 PM, Brent Laabs wrote: That last one has a special case available, but it's slightly less portable.  But afaik it works on all platforms we actually support: > perl6 -e '"screws/nuts/bolts/washers".path.parent.Str.say' screws/nuts/bolts :-)

Re: need s/ help

2018-05-01 Thread Brent Laabs
That last one has a special case available, but it's slightly less portable. But afaik it works on all platforms we actually support: > perl6 -e '"screws/nuts/bolts/washers".path.parent.Str.say' screws/nuts/bolts On Tue, May 1, 2018 at 4:37 PM, ToddAndMargo wrote: > On 05/01/2018 04:29 PM, Tod

Re: need s/ help

2018-05-01 Thread ToddAndMargo
On 05/01/2018 04:29 PM, ToddAndMargo wrote: On Tue, 1 May 2018 at 14:37 ToddAndMargo > wrote:     Hi All,     I am trying to change the last three letters of a string     $ perl6 -e 'my $x="abcabcabc"; $x ~~ s/"a.*"$/xyz/; say $x;'     abcabcabc     I want abcabc

Re: need s/ help

2018-05-01 Thread ToddAndMargo
On Tue, 1 May 2018 at 14:37 ToddAndMargo > wrote: Hi All, I am trying to change the last three letters of a string $ perl6 -e 'my $x="abcabcabc"; $x ~~ s/"a.*"$/xyz/; say $x;' abcabcabc I want abcabcxyz And, in real life, only the "a" will

Re: need s/ help

2018-05-01 Thread ToddAndMargo
On 05/01/2018 01:46 PM, Jonathan Scott Duff wrote: perl6 -e 'my $x="abcabca.*"; $x ~~ s/"a.*"$/xyz/; say $x;' There is no ".*" in the string ($x="abcabca.*")

Re: need s/ help

2018-05-01 Thread Jonathan Scott Duff
On Tue, May 1, 2018 at 8:37 AM, ToddAndMargo wrote: > Hi All, > > I am trying to change the last three letters of a string > > $ perl6 -e 'my $x="abcabcabc"; $x ~~ s/"a.*"$/xyz/; say $x;' > The double quotes around your text make it a string literal, so it will only match the literal string "a.*

Re: need s/ help

2018-05-01 Thread ToddAndMargo
On Tue, 1 May 2018 at 14:37 ToddAndMargo > wrote: Hi All, I am trying to change the last three letters of a string $ perl6 -e 'my $x="abcabcabc"; $x ~~ s/"a.*"$/xyz/; say $x;' abcabcabc I want abcabcxyz And, in real life, only the "a" will

Re: need s/ help

2018-05-01 Thread ToddAndMargo
On Tue, May 1, 2018 at 3:54 PM Simon Proctor > wrote: So what you what to match is a followed by zero or more not a's and then the end of the string. <[a]> is the perl6 regex for a range comprising of a alone you can negate that like so <-[a]>

Re: need s/ help

2018-05-01 Thread Thomas Klausner
Hi! On Tue, May 01, 2018 at 04:03:24PM +, Fernando Santagata wrote: > I guess there are more ways to do that than I can count :-) Which reminds me of http://paris.mongueurs.net/aplusplus.html Greetings, domm -- #!/usr/bin/perl http://domm.plix.at for(ref bless{

Re: need s/ help

2018-05-01 Thread Fernando Santagata
I guess there are more ways to do that than I can count :-) These two don't use a regex: ($a.comb)[0..^*-3].join ~ 'xyz'; # replace the last three letters of a string $a.subst: 'abc', 'xyz', :3rd; # replace the third occurrence of 'abc' On Tue, May 1, 2018 at 3:54 PM Simon Proctor wrote: > So

Re: need s/ help

2018-05-01 Thread Simon Proctor
So what you what to match is a followed by zero or more not a's and then the end of the string. <[a]> is the perl6 regex for a range comprising of a alone you can negate that like so <-[a]> Giving us perl6 -e 'my $x="abcabcabc"; $x ~~ s/a <-[a]>* $/xyz/; say $x;' (There's probably a better way,