in reply to multiple regex matches
Your code only finds numbers that are preceded by the strings cms or cqone. Since those strings are only before the 11111 on each line, that's all it will match. This will check for the string at the beginning of the line and then look for numbers:
my @list = ('CMS=11111','cms11111','cms00000011111','cms11111','cms:11 +111','cms 11111','cms 11111 22222 33333','cms 11111,22222,33333'); foreach (@list) { print "$_\n"; my @matches; if(/^(?:cms|cqone)/i) { @matches = /0*(\d+)/g; } foreach (@matches) { print "\t$_\n"; } }
|
|---|