With grep, you can use a question mark ? to signify an optional character, that is a character that is to be matches 0 or 1 times.
$ foo=qwerasdf
$ grep -Eo fx? <<< $foo
f
The question is does Bash String Manipulation have a similar feature? Something like
$ echo ${foo%fx?}
You’re probably talking about parameter expansion. It uses shell patterns, not regular expression, so
the answer is no.Upon further reading, I noticed that if you
you can use extended pattern matching which can achieve something similar to regex, albeit with slightly different syntax.
Check this out:
Works with parameter expansion too,