java.util.StringTokenizer(String str, String delim)

解决方案 »

  1.   

    StringTokenizer st = new StringTokenizer("this ;is; a; test",";");
         while (st.hasMoreTokens()) {
             println(st.nextToken());
         }
      

  2.   

    #include <string.h>
    char *strtok( char *s1, const char *s2 );
      

  3.   

    eaxmple:
    #include <stdio.h>
    #include <string.h>void main()
      {
        char *p;
        char *buffer;
        char *delims = { " .," };    buffer = strdup( "Find words, all of them." );
        printf( "%s\n", buffer );
        p = strtok( buffer, delims );
        while( p != NULL ) {
          printf( "word: %s\n", p );
          p = strtok( NULL, delims );
        }
        printf( "%s\n", buffer );  }produces the following:Find words, all of them.
    word: Find
    word: words
    word: all
    word: of
    word: them
    Find