Problems with tokenize

groovy, string

Solution

`tokenize` takes a list of possible tokens, so it's splitting on both `:` and `*`

You probably want `split` which takes a regular expression to split on (and returns a `String[]`):

def testStr = 'a:*b*c*d'

def tokens = testStr.split( /:\*/ )
assert tokens[ 0 ] == 'a'
assert tokens[ 1 ] == 'b*c*d'

Problem

I have ``` def testStr = 'a:*b*c*d' ``` I want to get ``` tokens[0]=='a' tokens[1]=='b*c*d' ``` I try ``` def tokens = testStr.tokenize(':*') ``` but get ``` tokens[0]=='a' tokens[1]=='b' tokens[2]=='c' tokens[3]=='d' ``` How can I do this thing

Original source