p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Intro Programming (http://p2p.wrox.com/forumdisplay.php?f=194)
-   -   Breaking a String (http://p2p.wrox.com/showthread.php?t=35219)

Macsood November 17th, 2005 12:52 PM

Breaking a String
 
I have created an ID for any entity by concatenating 3 different IDs. I want to break them into 3 IDs again.For further elaboration the ID i wan to break is:

"CityID-CategoryID-SubcategoryID"

Now i want to break this ID into 3 again.Could someone give me some ideas.



ciderpunx January 23rd, 2006 01:09 PM

In perl:
my ($city,$cat,$subcat) = split /-/,$ID;

In Java, you could use a StringTokenizer:
import java.util.*;
/*do ID concatenation, etc...*/
StringTokenizer st = new StringTokenizer(ID,"-");
city = st.nextToken();
cat = st.nexttoken();
subcat = st.nextToken();

Tutorial here:
http://www.devdaily.com/java/edu/pj/...pj010006.shtml

HTH
Charlie

--
Don't Stand on your head - you'll get footprints in your hair
                                           http://charlieharvey.org.uk
                                              http://charlieharvey.com


All times are GMT -4. The time now is 12:48 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.