remove all words from string after a specific pattern code example Example: java remove character from string after String result = input.split("-")[0];