user2036880 user2036880 - 21 days ago 4
Linux Question

Why does `\d` doesn't work in regular expression in sed

I am trying to use

\d
in regex in sed but it don't work

sed -re 's/\d+//g'


But this is working

sed -re 's/[0-9]+//g'

Answer

\d is a switch not a regular expression macro. If you want to use some predefined "constant" istead of [0-9] expression just try run this code

s/[[:digit:]]+//g
Comments