Check which characters/substrings a given string starts or ends with.