This example will show how to remove part of a string in groovy. The minus() method will remove part of a string which matches the parameter which can be either a String or a regular expression. The same operation can also be performed with the minus operator as shown in the second snippet.