| | |
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 add android applet application applications array automation bank bi binary blackberry block bluetooth class clear client code compile compiler component database development developmenthelp dice eclipse equation error event formatingtextintooltipjava fractal functiontesting game gameprogramming givemetehcodez graphics gui health html hyper idea image infinite int j2me j2seprojects java javac javame javaprojects jetbrains jni jpanel jtable julia learningresources lego linux mac main map method mobile myregfun netbeans notdisplaying number online openjavafx pearl problem program qt scanner screen scrollbar server set singleton sms sort spamblocker sql sqlserver storm string superclass swing system textfields thread threads time title tree tutorial-sample update variablebinding windows xor






