I’m attempting to use d in sed regex, but it’s not working:
sed -re 's/\d+//g'
However, this is working:
sed -re 's/[0-9]+//g'
Asked by user2036880
d is not a regular expression macro; it is a switch. Try running this code instead of the [0-9] expression if you want to utilize a predetermined “constant.”
Answered by Kamil
In sed, there is no such thing as a specific character group. You’ll have to utilize the numbers [0-9].
d in GNU sed adds a one-to-three-digit decimal character code in the range 0-255. As stated in the previous comment.
Answered by Ivaylo Strandjev
By passing -E to sed, you can utilize the Extended pattern. d and a few others will not be found in basic RegExp -E Regular expressions should be interpreted as extended (modern) regular expressions, not as basic regular expressions (BRE’s). Both formats are thoroughly described on the re format(7) manual page.
Answered by Fan Yer
Post is based on https://stackoverflow.com/questions/14671293/why-doesnt-d-work-in-regular-expressions-in-sed