The "?" in ".*?" makes ".*" matches as few characters as possible. Get rid of it.
Furthermore, the "g" in if (/.../g) makes no sense conceptually (check if there's a match, then check again to be sure?) or in practice (it has weird side effects). Get rid of it.
I dislike using global variables for no reason, so I'd write it
my $page2 = "Account number 12345678"; if ( my ($acct) = $page2 =~ /Account number (.*)/ ) { print "acct = $acct\n"; }
In reply to Re: Regex Question in Perl
by ikegami
in thread Regex Question in Perl
by mmittiga17
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |