in reply to String Matching
Produces the following output;#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; my @lines = ( "[HAVE 1324,2,32,324,5,643]", "[HAVE 4,213,5432,4]"); for my $line (@lines) { my @numbers; while ($line =~ /(\d+)/g) { push @numbers, $1; } print Dumper \@numbers; }
$VAR1 = [ '1324', '2', '32', '324', '5', '643' ]; $VAR1 = [ '4', '213', '5432', '4' ];
You could use s/// to remove the extra characters and use split on the commas if you like.
|
---|