in reply to Perl $
Your use of escaped brackets in the second regex leaves me uncertain about your original data... because my first thought was that you misunderstood the use of a character class. But on second thoughts, and taking a wild guess what at what the data might be (a number inside square brackets, in the original string), this example may clarify:
#!/usr/bin/perl use 5.016; use strict; use warnings; # 1039350 $_ = " this is a number [12345] "; if(/^\s*(.+)\s*/){ say "in outter 'if', \$1: $1"; $_ = $1; if($1 =~ /\[(\d+)\]/){ say "\t But in inner if, \$1 : $1"; } } =head output: in outter 'if', $1: this is a number [12345] But in inner if, $1 : 12345 =cut
A couple points, beyond those made above:
|
|---|