Posts Tagged ‘Substring’

Remove the first character of a string

To remove the first character of a string we can use Groovy’s range index notation. def name = ‘GROOVY’ def substring = name[1..-1]   assert substring == ‘ROOVY’

Remove the last character of a string

To remove the last character of a string we can use Groovy’s range index notation. def name = ‘GROOVY’ def substring = name[0..-2]   assert substring == ‘GROOV’