Delete the shortest match of string
in $var
from the beginning:
${var#string}
Delete the longest match of string
in $var
from the beginning:
${var##string}
Delete the shortest match of string
in $var
from the end:
${var%string}
Delete the longest match of string
in $var
from the end:
${var%%string}
Try:
var=foobarbar
echo "${var%b*r}"
> foobar
echo "${var%%b*r}"
> foo