Reputation: 111
Suppose I have an array
@arr = qw( 12 2 5 bba<1s54> 10 11 )
How I can delete non-numeric items from this array, in this case "bba<1s54>"
?
This unique "term" has format "bba<...>"
. Is it possible to use regex to delete it?
Upvotes: 0
Views: 110
Reputation: 67900
You can grep
the result for numbers only:
my @arr = qw(12 2 5 bba<1s54> 10 11);
@arr = grep /^\pN+$/, @arr;
If you know exactly what to remove, it is stricter to just remove that. E.g.:
@arr = grep !/bba<.*>/, @arr;
Upvotes: 6