tags:

views:

50

answers:

2

i want to how to get separate text from group of contents in java..

example

String a = "area href=\"hai.com\"  jkjfkjs </area> ndkjfkjsdfj dfjkdsjfl jkdf dljflsd fljdf kd;fsd a href=\"hoo.com\"  sdf</a> jisdjfi jdojfis joij";

i would like to get href link only..

how to write regex..

thanks and advance

+4  A: 

That should do the trick.

String text = ...
Matcher matcher Pattern.compile("href=\"(.*?)\"").matcher(text);
while (matcher.find())
{
   String hrefcontent = matcher.group(1);
}
Mnementh
you beat me to it :P
lugte098
+1  A: 

Try:

import java.util.regex.Pattern;
String textToSearch = "[Some text to search through]";
Pattern regex = Pattern.compile("href=\"(.*?)\"")
lugte098