aspose file tools*
The moose likes Beginning Java and the fly likes Splitting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Splitting" Watch "Splitting" New topic
Author

Splitting

Shelly Biswal
Greenhorn

Joined: Sep 07, 2007
Posts: 17
Hi All,

i need to split the following string : "//name['firstname = shelly']"
and get output as : firstname
shelly
and then i need to put them in string variables like
nameCategory = firstname and
myName =shelly
how do i do it?
do i need to use multiple split statements?
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

With String#subString(), get the string between character ' to ' ,
and split the string on regex "=" , then you can go !!

Hope this Help !


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Taariq San
Ranch Hand

Joined: Nov 20, 2007
Posts: 192
Originally posted by Sagar Rohankar:
and split the string on regex "=" , then you can go !!


That'll do, I'm not sure what the first line meant but that's enough.

"firstname = shelly".split("=") will give you a String[] with 2 elements, firstname and shelly, you'll just have to remove the whitespace with trim()
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Originally posted by Taariq San:


That'll do, I'm not sure what the first line meant but that's enough.


Look the string to split carefully, its enclosed in " ' " character..


So we need a substring enclosed in that character , once we get it , we can split it on "=",

Hope this clarifies !
darshan karle
Greenhorn

Joined: May 09, 2008
Posts: 28
hi shelly,

try to use StringTokenizer class of util package.

regards
darshan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Splitting
 
Similar Threads
not able to compile formbean file
can I change this to a while instead of a do?
javax.xml.parsers.Factory Configuration Error
Separating the Fraim from Menu
Splitting Strings