M
Morfys
hi,
I was having trouble understanding how regular conditional expressions
work. In particular, in this piece of code:
$str = "ttt, 2";
if(($result) = $str =~ /\w\w\w(?(?=, )(\d))/){
print "$result\n";
}
I don't understand why there is empty output versus "2".
The desired effect is that $result contain the digit following ", " if
it exists in the string.
I've tried almost every variation of the regular expression but I'm
missing something. Thanks in advance for any help.
I was having trouble understanding how regular conditional expressions
work. In particular, in this piece of code:
$str = "ttt, 2";
if(($result) = $str =~ /\w\w\w(?(?=, )(\d))/){
print "$result\n";
}
I don't understand why there is empty output versus "2".
The desired effect is that $result contain the digit following ", " if
it exists in the string.
I've tried almost every variation of the regular expression but I'm
missing something. Thanks in advance for any help.