Reputation: 394
I have a data set that has a delimiter and I like to remove all non numerical data but keep the decimal point if it has one.
I can't figure out how to include the decimal itself since right now it strips it with this:
$output =~ s/[^0-9|\|]*//gi;
A sample of the output is: 38.1mm|1013.88s|81%|22°
So I want to see: 38.1|1013.88|81|22
Thanks
Upvotes: 0
Views: 557
Reputation: 62164
The transliterate operator tr/// can delete characters:
$output =~ tr/0-9.|//cd;
Upvotes: 4
Reputation: 149050
Try this:
$output =~ s/[^\d.|]+//g;
This will remove any characters other than digits, .
, or |
.
Upvotes: 1