This discussion is archived
1 2 Previous Next 23 Replies Latest reply: Feb 19, 2010 3:11 AM by 807580 RSS

Non greedy Java Regex not working

800368 Newbie
Currently Being Moderated
I am trying to parse some HTML and using regex for it.

Here is the HTML I want to parse:
<a href="google.com">Lololo</a> <a href="tttt.com">Read More</a>
I want to find the second anchor tag with "Read More" text only.
The Regex I am using to parse the String is:
<a.*?>\s*Read More.*?</a>
But I am still getting the entire string back after the regex match instead of only the second A tag with Read More text.

Can anyone help explain what is wrong in my regex?

I am using Java 6 with Eclipse IDE 3.4.
1 2 Previous Next