Menu

#2 split method that returns a String array

open
nobody
5
2002-11-25
2002-11-25
No

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

Discussion

  • Sergey A. Samokhodkin

    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?

     
  • Marco Hunsicker

    Marco Hunsicker - 2002-11-28

    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.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.