1 2 Previous Next 23 Replies Latest reply on Feb 21, 2010 8:58 PM by jschellSomeoneStoleMyAlias

    Non greedy Java Regex not working

      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