title: Java regex throwing exception for no match found when pattern found in line
body: <p>I am dying trying to figure out why a regex won't match. Any help is much appreciated. I'm going line by line of a web page (that works fine), but I need to pull out the links for each line. The application will check to see if there is a link in the line, but I need to actually pull out the URL. help?</p>
  
  <pre><code>Pattern p = Pattern.compile("^.*href=\"([^\"]*)");
  Matcher m = p.matcher(result);
  String urlStr = m.group();
  links.add(urlStr);
  </code></pre>
  
  <p>The error message I keep getting is this:</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalStateException: No match found
  at java.util.regex.Matcher.group(Matcher.java:485)
  </code></pre>
  
  <p>Even though 'result' has a link reference (hxxp://www.yahoo.com) in it. </p>
  
  <p>links is an ArrayList fyi. Thanks in advance!</p>