| 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: 2896
|
|
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: 189
|
|
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: 2896
|
|
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
|
 |
 |
|
|
subject: Splitting
|
|
|