Possible Duplicate:
Extract text and links from HTML using Regular Expressions
Given an string containing HTML such as:
<td scope="row">1</td> <td scope="row"></td> <td scope="row"><a href="/Archives/directory.htm">directoryfile.htm</a></td> <td scope="row">directoryfile</td> <td scope="row">104569</td> </tr> <tr class="blueRow"> <td scope="row">2</td> <td scope="row"></td> <td scope="row"><a href="/Archives/historicaldata.htm</a></td> <td scope="row">historicaldata</td> <td scope="row">40361</td> </tr> <tr> <td scope="row"> </td> <td scope="row"><span class="blue">Complete submission text file</span></td> <td scope="row"><a href="/Archives/businessagenda.txt</a></td> <td scope="row">businessagenda;</td> <td scope="row">146701</td>
I want to just grab the link for historicaldata using regex. However, it seems that my program is not finding the link and I do not see the problem as the regex works on the tester. Can you guys see what's the problem?
I understand that regex is not the best thing to use with HTML but I just want to try it. Thanks everyone!
Pattern data = Pattern.compile("Archives.*\s.*historicaldata");
Matcher test1= data.matcher(inputHTML);
while (test1.find()) {
System.out.println("Test: Now matching"); // Doesn't print
}