iam not able to split string using regex the following code iam using
String[] splitedEmail=email.split(/\\n\;\,\s/);
it's not splitting it's giving the same
Groovy Split() with Regular Expression
Groovy String's split() method can also take a regular expression as a delimiter. Here are some examples:
Split by a single digit:
def sampleText = "A1B23C456D"
println sampleText.split(/\d/)
Since extra occurance of delimiter will yield empty Strings, the code will render:
[A, B, , C, , , D]
Split by 2 digits:
def sampleText = "A1B23C456D"
println sampleText.split(/\d\d/)
Since 23 and 45 are the only consecutive two digits, we will have the result:
[A1B, C, 6D]
Split by any number of digits:
def sampleText = "A1B23C456D"
println sampleText.split(/\d+/)
Will split the String with any length of digit sequence, hence the expected output:
[A, B, C, D]
More details please refer here.
email?