I thought I understood the use of optional in (when the shell option is enabled ) and by default in . For example, in : ?(pattern-list) bash extglob kshbash
$ shopt -s extglob
$ V=35xAB
$ echo "${V#?(35|88)x}" "${V#35}"
AB xAB
But if the prefix pattern being matched is only one ?()or one *()that introduces what I call optional patterns , it is 35not skipped if not used : ##
$ echo "${V#?(35|88)}" "${V#*(35|88)}"
35xA 35xA
$ echo "${V##?(35|88)}" "${V##*(35|88)}"
xA xA
The same behavior is reported when ?(), and *()are used in the template suffix matching (using %and %%):
$ echo "${V%5?(xA|Bz)}"
3
$ echo "${V%?(xA|Bz)}" "${V%*(xA|Bz)}"
35xA 35xA
$ echo "${V%%?(xA|Bz)}" "${V%%*(xA|Bz)}"
35 35
bash 3.2.25, 4.1.2 4.1.6, , , , .
- ?