How does extglob work with shell parameter expansion?
问题 I thought I understood the use of the optional ?(pattern-list) in bash (when extglob shell option is on) and by default in ksh. For example in bash : $ shopt -s extglob $ V=35xAB $ echo "${V#?(35|88)x}" "${V#35}" AB xAB But when the matching prefix pattern is just one ?() or one *() , which introduce what I call optional patterns , the 35 is not omitted unless ## is used: $ echo "${V#?(35|88)}" "${V#*(35|88)}" # Why 35 is not left out? 35xA 35xA $ echo "${V##?(35|88)}" "${V##*(35|88)}" # Why