user2036880 user2036880 - 1 year ago 89
Linux Question

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

I am trying to use

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 Source

\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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download