$ perl -ple 's/[^.\d+]//g' This has no numbers, dot or plus This has 1 dot. 1. This has 1234567890 + . 1234567890+.