> On Mon, May 06, 2019 at 07:12:39PM -0700, Tony Ewell via perl6-users
wrote:
>> Hi All,
>>
>> What am I doing wrong here?
>>
>> $ p6 'my $x="\$1.23"; $x~~s/("\$") (.*?)/$1USD/; say $x;'
>> USD1.23
>>
>> I am expecting to see `1.23USD`
>>
>> Many thanks,
>> -T
On 5/7/19 3:05 PM, Patrick R. Mich
The (.*?) pattern will match an empty string.
Thus $0 gets the dollar sign, $1 is "", and "$" ~ "" (i.e., "$") gets replaced
by "" ~ "USD" (i.e., "USD").
So the net result is to replace the single dollar sign by "USD", resulting in
"USD1.23".
You might want to remove the ? modifier from .*?
Hi All,
What am I doing wrong here?
$ p6 'my $x="\$1.23"; $x~~s/("\$") (.*?)/$1USD/; say $x;'
USD1.23
I am expecting to seeĀ `1.23USD`
Many thanks,
-T
On Tue, 7 May 2019 at 13:10, ToddAndMargo via perl6-users
mailto:[email protected]>> wrote:
Hi All,
What am I doing wrong here?
$ p6 'my $x="\$1.23"; $x~~s/("\$") (.*?)/$1USD/; say $x;'
USD1.23
I am expecting to see `1.23USD`
Many thanks,
-T
On 5/6/19 8:28
On Tue, 7 May 2019 at 13:10, ToddAndMargo via perl6-users
mailto:[email protected]>> wrote:
Hi All,
What am I doing wrong here?
$ p6 'my $x="\$1.23"; $x~~s/("\$") (.*?)/$1USD/; say $x;'
USD1.23
I am expecting to see `1.23USD`
Many thanks,
-T
On 5/6/19 8:24
The .*? expression is not matching anything. I think you want to use .+
perl6 -e 'my $x="\$1.23"; $x~~s/("\$") (.*?)/$0:$1:USD/; say $x;'
$::USD1.23
perl6 -e 'my $x="\$1.23"; $x~~s/ \$(.+) /$0USD/; say $x'
1.23USD
On Tue, 7 May 2019 at 13:10, ToddAndMargo via perl6-users <
[email protected]
Hi All,
What am I doing wrong here?
$ p6 'my $x="\$1.23"; $x~~s/("\$") (.*?)/$1USD/; say $x;'
USD1.23
I am expecting to seeĀ `1.23USD`
Many thanks,
-T
--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~~