| | |
Tokenize
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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?
Views: 778 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for Java
-xlint android animated api apple applet application arguments array arrays automation binary blackberry block bluetooth chat class classes client code component database detection developmenthelp draw eclipse encode error event exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer iphone j2me j2seprojects java javac javaprojects jmf jni jpanel julia lego linux list loop loops mac map method methods mobile netbeans newbie number object online oracle os page print problem program programming project recursion scanner screen server set singleton size sms socket sort sql string swing template test textfields threads time title transfer tree tutorial-sample update windows working






