| Author |
get text between two tags in a string
|
Janne ukko
Greenhorn
Joined: Nov 25, 2004
Posts: 10
|
|
Hello! if i have a String that look like this String s="[tag]jajasljalfjasljldjdasld[/tag][tag12]afalejljldjlefe[/tag12]"; how can i do to only get the text that is inside the [tag][/tag] regards
|
 |
Joel McNary
Bartender
Joined: Aug 20, 2001
Posts: 1815
|
|
Look at the .indexOf and .substring methods
|
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
Well, we're in advanced so I'll bring up Regular Expressions. You can compile a Pattern object then use its methods to get a Matcher for your input string and use find() and group() methods to get what was found. I hope that used just enough of the right words to get you started in the JavaDoc. Holler if you'd like examples. I have something almost exactly like what you need.
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
 |
|
|
subject: get text between two tags in a string
|
|
|