split method that returns a String array
Brought to you by:
samokhodkin
Hi,
I'm currently evaluating your package and I am quite
satisfied so far. What you be nice (for me, at least)
to have in a future version would be a Pattern.split()
method that returns a String array of the found matches
instead of the Pattern.tokenizer() that returns a
RETokenizer instance.
Cheers,
Marco
Logged In: YES
user_id=367459
It's not clear from the message, what should such metod return:
an array of matches or an array of splitted chunks?
Do you know of this way:
String[] chunks=pattern.tokenizer(string).split();
I'm also going to add similar method to MatchIterator, so it
may be used like following:
String[] matches=myPattern.matcher(string).findAll().values
(0);
where the 0 is the group number (in this case the whole match).
Or did you mean something different?
Logged In: YES
user_id=44430
>Do you know of this way:
>String[] chunks=pattern.tokenizer(string).split();
Ah, I missed that one. It is not documented, BTW.
It would be cool if you could support both: array of matches
*and* array of splitted chunks! (just like Perl does)
For the string "de.hunsicker.util"
[.] returns chunks, i.e. { de, hunsicker, util }
([.]) returns matches, i.e. {de, ., hunsicker, ., util }
Thanks.