I am making a simple string tokenizer in Swift, as in Java, but it really does not work for me.
The end of each line in my data source is limited to "^" and the data is separated by a comma.
For example: "line 1, line 2, line 3, ^, line 1, line 2, line 3, ^"
This is what I will do in Java ... (I only need the first two rows in each row of data)
String delimeter = "^"; StringTokenizer tokenizedString = new StringTokenizer(responseString,delimeter); String [] stringArray = new String [tokenizedString.countTokens()]; StringTokenizer tokenizedAgain; String str1; String str2; String token; for(int i =0; i< stringArray.length; i ++) { token = tokenizedString.nextToken(); tokenizedAgain = new StringTokenizer(token, ","); tokenizedAgain.nextToken(); str1 = tokenizedAgain.nextToken(); str2 = tokenizedAgain.nextToken(); }
If someone can point me in the right direction, that would be really helpful.
I looked at this: Swift: split a string into an array
and this: http://www.swift-studies.com/blog/2014/6/23/a-swift-tokenizer
but I cannot find other resources for String Tokenizing in Swift. Thanks!
source share