www.un.org/Depts/DGACM/index_spanish.htm I ve tocompet a regularexpression, Deposit in aerra:
#!/bin/env perl
use warnings;
use strict;
my $expr = qr/s*(w+([d+])?)s+(w+([d+])?)/sx;
$str = "abcd[3] xyzg[4:0]";
if ($str =~ m/$expr/) {
print "
%%%%%%%%% $`-----$&-----$
";
}
else {
print "
********* NOT MATCHED
";
}
但是,我不停在美元和纸浆中;
%%%%%%%%% -----abcd[3] xyzg-----[4:0]
But expecting, it shouldn t go inside the if clause. What is intended is:
if $str = "abcd xyzg" => %%%%%%%%% -----abcd xyzg----- (CORRECT)
if $str = "abcd[2] xyzg" => %%%%%%%%% -----abcd[2] xyzg----- (CORRECT)
if $str = "abcd[2] xyzg[3] => %%%%%%%%% -----abcd[2] xyzg[3]----- (CORRECT)
if $str = "abcd[2:0] xyzg[3] => ********* NOT MATCHED (CORRECT)
if $str = "abcd[2:0] xyzg[3:0] => ********* NOT MATCHED (CORRECT)
if $str = "abcd[2] xyzg[3:0]" => ********* NOT MATCHED (CORRECT/INTENDED)
but output is %%%%%%%%% -----abcd[2] xyzg-----[3:0] (WRONG)
OR better to say this is not intended.
In this case, it should/my_expectation go to the else block.
Even I don t know, why $& take a portion of the string (abcd[2] xyzg), and $ having [3:0]?
HOW?
It should match the full, not a part like the above. If it didn t, it shouldn t go to the if clause.
Can anyone please help me to change my $expr pattern, so that I can have what is intended?