Re: I need help with pattern matching

2017-03-13 Thread ToddAndMargo

On 03/13/2017 01:16 AM, Elizabeth Mattijsen wrote:



On 13 Mar 2017, at 08:27, ToddAndMargo  wrote:

Hi All,

What am I doing wrong here?

$ perl6 -e 'my $x="abc\(123\)def"; $x ~~ m/(abc\))(123)(\(def)/; say "$x\n\$0=<$0>  
\$1=<$1>  \$2=<$2>\n";'

Use of Nil in string context
 in block  at -e line 1
Use of Nil in string context
 in block  at -e line 1
Use of Nil in string context
 in block  at -e line 1

abc(123)def
$0=<>  $1=<>  $2=<>


You escaped the parens around (123) incorrectly:

$ 6 'my $x="abc\(123\)def"; $x ~~ m/(abc)\((123)\)(def)/; say "$x\n\$0=<$0>  \$1=<$1>  
\$2=<$2>\n"'
abc(123)def
$0=  $1=<123>  $2=


Liz



Hi Liz,

Thank you!  I must have been seeing things!

perl6 -e 'my $x="abc\(123\)def"; $x ~~ m/(abc\()(123)(\)def)/; say 
"$x\n\$0=<$0>  \$1=<$1>  \$2=<$2>\n";'

abc(123)def

$0=  $1=<123>  $2=<)def>


Many thanks,
-T


--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: I need help with pattern matching

2017-03-13 Thread Andreas Mueller
 $ perl6 -e 'my $x="abc(123)def"; say $x ~~ m/(abc)(\(123\))(def)/;'

-am

On 13.03.17 00:27, ToddAndMargo wrote:
> Hi All,
> 
> What am I doing wrong here?
> 
> $ perl6 -e 'my $x="abc\(123\)def"; $x ~~ m/(abc\))(123)(\(def)/; say
> "$x\n\$0=<$0>  \$1=<$1>  \$2=<$2>\n";'
> 
> Use of Nil in string context
>   in block  at -e line 1
> Use of Nil in string context
>   in block  at -e line 1
> Use of Nil in string context
>   in block  at -e line 1
> 
> abc(123)def
> $0=<>  $1=<>  $2=<>
> 
> 
> Many thanks,
> -T
> 
> 
> -- 
> 
> Yesterday it worked.
> Today it is not working.
> Windows is like that.
> 

-- 
Andreas Müller - Raum: 35/114b - Tel: 2875


Re: I need help with pattern matching

2017-03-13 Thread Elizabeth Mattijsen

> On 13 Mar 2017, at 08:27, ToddAndMargo  wrote:
> 
> Hi All,
> 
> What am I doing wrong here?
> 
> $ perl6 -e 'my $x="abc\(123\)def"; $x ~~ m/(abc\))(123)(\(def)/; say 
> "$x\n\$0=<$0>  \$1=<$1>  \$2=<$2>\n";'
> 
> Use of Nil in string context
>  in block  at -e line 1
> Use of Nil in string context
>  in block  at -e line 1
> Use of Nil in string context
>  in block  at -e line 1
> 
> abc(123)def
> $0=<>  $1=<>  $2=<>

You escaped the parens around (123) incorrectly:

$ 6 'my $x="abc\(123\)def"; $x ~~ m/(abc)\((123)\)(def)/; say "$x\n\$0=<$0>  
\$1=<$1>  \$2=<$2>\n"'
abc(123)def
$0=  $1=<123>  $2=


Liz