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, this was just my first attempt)

On Tue, 1 May 2018 at 14:37 ToddAndMargo <toddandma...@zoho.com> 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 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
>

Reply via email to