You could just use the last hyphen. It's not as simple since you need to scan the whole string, but it certainly doesn't seem like a challenge to me.

Yes but why pay that runtime cost for a problem the user can solve in human time using grep?