I'm dying trying to figure out why the regex won't match. Any help is much appreciated. I go along the line of the web page (this works great), but I need to pull out the links for each line. The application will check if there is a link in the line, but I need to actually pull out the url. to help?
Pattern p = Pattern.compile("^.*href=\"([^\"]*)"); Matcher m = p.matcher(result); String urlStr = m.group(); links.add(urlStr);
The error message I get is the following:
Exception in thread "main" java.lang.IllegalStateException: No match found at java.util.regex.Matcher.group(Matcher.java:485)
Despite the fact that in the "result" there is a link to the link (hxxp: //www.yahoo.com).
References
is an ArrayList fyi. Thanks in advance!
java regex matcher
johwiltb
source share