| | |
Tokenize
![]() |
How do you need your tokens to be parsed?
An example...
An example...
java Syntax (Toggle Plain Text)
public class TokenMaster{ public static void main(String... args){ String myReallyBIGString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n" + "ALPHABETICAL!\n" + "SOMETIMES I FEEL I'VE GOT TO 'AH-AH' RUN AWAY, I'VE GOT TO... " + "'AH-AH' GET AWAY!!!\n" + "RING RING RING RING RING RING RING... BANANA PHONE! 'doot, doot doot doot doot doot'" + "DING-DONG DING-DONG DING-DONG DING... BANANA PHONNNNNE!!!!!"; String tokens[] = myReallyBIGString.split("\n"); // each token is determined by the newline character for(String element : tokens) System.out.println(element); // printing the individual tokens generated from String.split("\n") System.out.println("\nTokens counted: " + tokens.length); } }
Last edited by Alex Edwards; Sep 2nd, 2008 at 3:14 am.
Or not, because StringTokenizer is considered an Obsolete class that receives no further support in future releases.
Furthermore, String.split() is better because it takes regular expressions into consideration. StringTokenizer does not.
Furthermore, String.split() is better because it takes regular expressions into consideration. StringTokenizer does not.
Last edited by Alex Edwards; Sep 3rd, 2008 at 11:32 am.
•
•
Join Date: Sep 2008
Posts: 18
Reputation:
Solved Threads: 1
You may use the special PHP function strtok
<?php
$myText="online pharmacy web solution";
$strToken=strtok($myText," ");
while($strToken){
echo $strToken."<br>";
$strToken=strtok(" ");
}
?>
this my hel;p u
<?php
$myText="online pharmacy web solution";
$strToken=strtok($myText," ");
while($strToken){
echo $strToken."<br>";
$strToken=strtok(" ");
}
?>
this my hel;p u
![]() |
Similar Threads
- Tokenize (Java)
- tokenize an input text file.. (Java)
- Parse or Tokenize String (C++)
- how to tokenize a long string by using another string (Java)
- Is there a way to tokenize an array of strings (C++)
- help on using StringTokenizer to read and compute multiple lines from text (Java)
- Scanf Equivalent (Java)
- Conver int Array into a String (Java)
- string translation (Java)
Other Threads in the Java Forum
- Previous Thread: Runtime classname of null object
- Next Thread: How to insert data read from text file into linked list?
| Thread Tools | Search this Thread |
-xlint actionlistener android api applet application array arrays automation bi binary blackberry block bluetooth character chat class client code compile compiler component consumer database desktop developmenthelp eclipse error fractal freeze ftp game gameprogramming givemetehcodez graphics gui html ide image integer j2me j2seprojects java javac javaee javaprojects jetbrains jni jpanel jtable julia learningresources lego linked linux list loops mac map method methods mobile netbeans newbie notdisplaying number online printf problem program programming project properties qt recursion researchinmotion rotatetext rsa scanner screen server set singleton sms sort sql string swing system textfields threads time title tree tutorial-sample update variablebinding windows working xor






