| | |
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 |
account android api applet application array arrays automation bidirectional binary birt bluetooth class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error errors exception expand fractal game givemetehcodez graphics gui guidancer homework html ide image inetaddress inheritance integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield jtree julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source oracle plazmic print problem program project property recursion ria scanner search server set sharepoint smart sms smsspam sort sourcelabs splash sql sqlite static string subclass support swing testautomation threads tree unlimited webservices windows






