Can anyone please explain to me what the first regular expression test will match, but the second one won't?
#!/usr/bin/perl use strict; use warnings; my $a = 'abc == 123'; if ($a =~ /^(.*?)==(.*)$/) { print "This will match\n"; print "First: $1\nLast: $2\n"; } if ($a =~ /^(.*?)\b==\b(.*)$/) { print "This will not match\n"; print "First: $1\nLast: $2\n"; }
I need to use the non-greedy match in the first part of the expression becuase I need to find the first occurrence of the '=='.
In reply to Regular Expression Question by VingInMedina
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |