Shortest match:
$ a='I am a string' $ echo "${a%a*}" I am
Longest match:
$ echo "${a%%a*}" I