Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

getting content of string between two quotes

Hi All...
I am trying to get the content that is in between two href tags of a string. And after i get that content, i will need to process it further on. But how do i get only the content as shown below..

<a href="/detail.html?detailID=56141">

i only want "/detail.html?detailID=56141". Please help !!!...

thanks,
[353 byte] By [crazydiode] at [2007-11-11 8:51:29]
# 1 Re: getting content of string between two quotes
have a look at the indexOf() and substring() methods in the String class.

That will allow you to get the index of a particular char or string, and then you can put those numbers into the substring method to give you your string sans the HTML bit.
masher at 2007-11-11 22:34:08 >
# 2 Re: getting content of string between two quotes
another approach: pattern and matcher classes for regex. but more difficult for people who are not fammiliar to regular expressions.
graviton at 2007-11-11 22:35:19 >
# 3 Re: getting content of string between two quotes
public String token(String tokens){
int a = 0;
char s = tokens.charAt(a);
String token = "";

while(s != '>' ) {
if(s == '<')
token += "";
else{
token += s ;

}
a++;
s = tokens.charAt(a);
}
hagi at 2007-11-11 22:36:12 >
# 4 Re: getting content of string between two quotes
Soryy for the mistake

public String token(String tokens){
hagi at 2007-11-11 22:37:17 >
# 5 Re: getting content of string between two quotes
Again :D
Soryy for the mistake

public String token(String tokens){
int a = 0;
char s = tokens.charAt(a);
String token = "";

while(s != '>' ) {
if(s == '<')
token += "";
else{
token += s ;

}
a++;
s = tokens.charAt(a);
}
return tokens;
hagi at 2007-11-11 22:38:15 >
# 6 Re: getting content of string between two quotes
Ah I am too tired,
return tokens replace with;

return token;

Sorry, sorry, sorry very much
As I said I am too tired today
Again Sorry
hagi at 2007-11-11 22:39:14 >
# 7 Re: getting content of string between two quotes
another approach: pattern and matcher classes for regex. but more difficult for people who are not fammiliar to regular expressions.
For HTML parsing there is a set of classes ready made. I have attatched a simple app here that uses some of these features to extract the links, image-urls and the readable text from an HTML document.
sjalle at 2007-11-11 22:40:24 >