I want to remove all floating point numbers from a string using sed. Therefore I use
sed -e 's/[ +-]?[0-9]*\.[0-9]*//g'
But it does not work:
echo 1.2456 | sed -e 's/[ +-]?[0-9]*\.[0-9]*//g'
gives 1.2456. If I remove the [ +-]? block, it works for positive numbers.
The
?sign is an extended regex character.sedneeds to be called with the-roption to enable the extended expressions.