On 27/04/2011 11:47, jet speed wrote:
Please could you advice, how can i write a regular expression for the
line below to capture 0079 and 6000097000029260057253303030373
0079 Not Visible 6000097000029260057253303030373
i tried this one, no luck
/(^\d{4})\s\w+\s\w+\s+\d+/ig)
It works fine! You are simply not capturing the second sequence of
digits. This
use strict;
use warnings;
for ('0079 Not Visible 6000097000029260057253303030373') {
print /(^\d{4})\s\w+\s\w+\s+(\d+)/ig ? "$1 $2" : 'no match';
}
prints '0079 6000097000029260057253303030373'.
But, depending on your data, there may be no need to match the line so
precisely. This does the same thing
use strict;
use warnings;
for ('0079 Not Visible 6000097000029260057253303030373') {
my @n = (split)[0,-1];
print "@n";
}
HTH,
Rob
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/