I've been unable to get the "?" operator to work in SED. It works fine in GREP. Example:

echo "nathan" | sed "s/na[t]\{0,1\}han/_/g"
_
(that works)

echo "nathan" | sed "s/na[t]\?han/_/g"
nathan
(that doesn't work)

/? and /{0,1\} should be functionally identical, zero or one matches of the preceding pattern. Both work in GREP, but only the range one works in SED, and I can't find any explanation for why. I've tried different variations of escaping, quoting, and options like -E and -e.


I work for the Department of Redundancy Department