How would I get the matching strings?
I would like to get the figure after "text-align:right" - but only if the string machtes to following string.
<td style="text-align:left;">whatever characters</td>
<td style="text-align:right;">whatever characters</td>
The text I am searching looks like this:
<td style="text-align:left;">all kinds of 12.:-aäüKFfk characters </td>
<td style="text-align:right;">100.00</td>
<td style="text-align:right;">200.00</td>
...more text...
<td style="text-align:left;">all kinds of 12.:-aäüKFfk characters</td>
<td style="text-align:right;">300.00</td>
<td style="text-align:right;">400.00</td>
This should print out to the console window the figures 100.00 and 300.00 But it does not show anything.
Pattern pattern = Pattern.compile("<td style=\"text-align:left;\">.</td>" + "\\s+" + "<td style=\"text-align:left;\">(.*?)</td>");
Matcher matcher = pattern.matcher(alltext);
while (matcher.find()) {
System.out.println(matcher.group(1));}
If I try only
Pattern pattern = Pattern.compile("<td style=\"text-align:left;\">(.*?)</td>");
Matcher matcher = pattern.matcher(alltext);
while (matcher.find()) {
System.out.println(matcher.group(1));}
it prints out all the figures 100.00, 200.00, 300.00 and 400.00
So the problem has to be in the this part
Pattern.compile("<td style=\"text-align:left;\">.</td>" + "\\s+" +
What could be the problem and how could it be solved?