develooper Front page | perl.perl6.users | Postings from May 2018

need s/ help

Thread Next
From:
ToddAndMargo
Date:
May 1, 2018 13:37
Subject:
need s/ help
Message ID:
7d3c36f5-b446-fcfd-cedb-2e546133682d@zoho.com
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 be a know letter.
Everything else will vary.  And the "a" will repeat a lot.
I am only interested in changing the last "a" and everything
that comes after it.

Many thanks,
-T

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