What is split() in groovy?
Overview
split() is a function in groovy that splits the String around matches of the given regular expression.
Syntax
String[] split(String regex)
Parameters
The function takes in one parameter regex.
regex is the delimiting regular expression.
Return value
The function returns the array of strings calculated by splitting the string around matches of regex.
Code
class Example {static void main(String[] args) {String val_one = "Hello-Edpresso";String[] str;str = val_one.split('-');for( String val : str )println(val);}}
Output
Hello
Edpresso