On Sat, Sep 23, 2017 at 3:54 PM, ToddAndMargo > wrote:
>> Hi All,
>>
>> Question. Can I chain these two substitutions together?
>>
>> $ perl6 -e 'my $x="State : abc "; $x ~~ s/.*?" : "//; $x ~~ s/"
>> ".*//;
Here's another solution:
my $x="State : abc "; $x = $x.subst(/.*?" : "/, "").subst(/ " "+
/,""); say "<$x>"; #
-y
On Sat, Sep 23, 2017 at 3:54 PM, ToddAndMargo wrote:
> >> Hi All,
> >>
> >> Question. Can I chain these two substitutions together?
> >>
> >> $
>> Hi All,
>>
>> Question. Can I chain these two substitutions together?
>>
>> $ perl6 -e 'my $x="State : abc "; $x ~~ s/.*?" : "//; $x ~~ s/"
>> ".*//; say "<$x>";'
>>
>>
>>
>> Many thanks,
>> -T
On 09/23/2017 07:58 AM, raiph mellor wrote:
You want to do two things:
1. match/replace
You want to do two things:
1. match/replace something
2. match/replace something else
To do this in one command you need:
* `:g` to tell P6 to keep going after the first match
* `||` to tell P6 to match what's on the left first, or if that fails,
what's on the right
Which yields:
my $x="