I was testing some string manipulation stuff in a bash
script and I've quickly realized it doesn't understand regular expressions (at least not with the syntax I'm using for string operations), then I've tried some glob expressions and it seems to understand some of them, some not. To be specific:
FINAL_STRING=${FINAL_STRING//<title>/$(get_title)}
is the main operation I'm trying to use and the above line works, replacing all occurrences of <title>
with $(get_title)
on $FINAL_STRING
... and
local field=${1/#*:::/}
works, assigning $1
with everything from the beginning to the first occurrence of :::
replaced by nothing (removed). However #
do what I'd expect ^
to do. Plus when I've tried to use the {,,}
glob expression here:
FINAL_STRING=${FINAL_STRING//{<suffix>,<extension>}/${SUFFIX}}
to replace any occurrence of <suffix>
OR <extension>
by ${SUFFIX}
, it works not.
So I see it doesn't take regex and it also doesn't take glob patterns... so what Does it take? Are there any exhaustive listing of what symbols/expressions are understood by plain bash string operations (particularly substring replacement)? Or are *
, ?
, #
, ##
, %
and %%
the only valid stuff?
(I'm trying to rely only on plain bash, without calling sed
or grep
to do what I want)