Aha, regular expressions, a topic I appreciate a lot: not easy to master, but powerful.
If you are interested with an introductory article, I wrote a
tutorial on regular expressions some years ago. Feedback welcome.
Chrisir, he dumps the sTokens array, there is only one element. Which is normal. See the match() reference:
The match() function is used to apply a regular expression to a piece of text, and return matching groups (
elements found inside parentheses) as a String array. No match will return null. If no groups are specified in the regexp, but the sequence matches,
an array of length one (with the matched text as the first element of the array) will be returned.
To use the function, first check to see if the result is null. If the result is null, then the sequence did not match. If the sequence did match, an array is returned. If there are groups (
specified by sets of parentheses) in the regexp, then the contents of each will be returned in the array.
Element [0] of a regexp match returns the entire matching string, and the match groups start at element [1] (the first group is [1], the second [2], and so on).
I highlighted the parts relative to the above issue: the expression has no parentheses, so no capture (groups), and only the whole match is returned.
match() won't iterate over the matching elements of the string. You have to do it yourself. But match() is a bit primitive (simplified) for this, as it doesn't take an offset, so it makes hard to skip previously found matches.
The methods available in String are also simplified shortcuts. If you want to do advanced stuff, you have to go for the real classes,
Pattern
and friends.