String functions
Fields:
length
- string lengthlower
- lower case stringupper
- upper case stringchars
- ASCII characters array
Functions:
trim()
- removes any leading and trailing whitespaces in stringstartsWith(str, offset = 0)
- checks whether the string starts with the substring str at offsetendsWith(str)
- checks whether the string ends with the strmatches(regex)
- checks whether the string matches regex patterncontains(str)
- checks whether the string contains substring strequalsIgnoreCase(str)
- checks equality of two strings ignore case (tEsT = TEST)isEmpty()
- returns true, if the string is empty
In addition, there are automatic function extensions available if the function accepts a string as the first argument:
str = " ababcaab "
println indexOf(str, "abc")
println str.indexOf("abc")
def isBlank(s) = s.trim().isEmpty()
println isBlank(str)
println str.isBlank()