I would like to split this text contact into 3 parts separated by -
.
In each part we have: name, function, number and email.
Then I'd like to separate each part by \n
.
def contact = '''name1
Function1
: 1111
: name1@mail.com-name2
Function2
: 2222
: name2@mail.com-name3
Function3
: 3333
: name3@mail.com
'''
I've tried this:
def contact_part = contact.split('-')
println contact_part[0]
def data = contact_part.split('\n') //line 15
println data[1]
But I got this error:
groovy.lang.MissingMethodException: No signature of method: [Ljava.lang.String;.split() is applicable for argument types: (java.lang.String) values: [ ] Possible solutions: split(groovy.lang.Closure), wait(), sort(), init(), tail(), toList() at Script1.run(Script1.groovy:15)
Thank you.