"If" doesn't loop, so when the test returns true, it prints $1. You'll need to replace the if with a looping construct or (my preference) use the regex in list context:
@text = ( $text =~ /([a-zA-Z0-9]+\s+[z]{15}\s+[a-z0-9]+)/g) if(@text){ print "first: " . shift(@text) . "\n" if (@text); print "second: " . shift(@text) . "\n" if (@text); } else{ print "Search failed\n"; }
emc
In reply to Re: regex question
by swampyankee
in thread regex question
by goff
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |