How to match digits followed by a dot using sed


I'm trying to use sed to substitute all the patterns with digits followed immediately by a dot (such as 3., 355.) by an empty string. So I try:

sed 's/\d+\.//g' file.txt

But it doesn't work. Why is that?

Best Answer

Because sed is not perl -- sed regexes do not have a \d shorthand:

sed 's/[[:digit:]]\+\.//g'

sed regular expression documentation here.

Related Question