import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "£\\d+\\.\\d{1,2}";
final String string = "<div style=\"float:left;\"><a class=\"url\" href=\"http://www.amazon.co.uk/AllThingsAccessory%C2%AE-Sports-Running-Jogging-... src=\"http://ecx.images-amazon.com/images/I/51bQWjrCioL._SL160_.jpg\" alt=\"AllThingsAccessory Sports\" border=\"0\" hspace=\"0\" vspace=\"0\" /></a></div><span class=\"riRssTitle\"><a href=\"http://www.amazon.co.uk/AllThingsAccessory%C2%AE-Sports-Running-Jogging-...® Sports Running Jogging Gym Armband Arm Band Case Cover Holder For iPhone 6 5 5S 5C 4S 4</a></span> <br /><span class=\"riRssContributor\">AllThingsAccessory®</span> <br /><img src=\"http://g-ecx.images-amazon.com/images/G/02/x-locale/common/icons/uparrow... width=\"13\" align=\"abstop\" alt=\"Ranking has gone up in the past 24 hours\" title=\"Ranking has gone up in the past 24 hours\" height=\"11\" border=\"0\" /> <font color=\"green\"><strong>52,006%</strong></font> Sales Rank in Sports & Outdoors: 50 (was 26,053 yesterday) <br /> <img src=\"http://g-ecx.images-amazon.com/images/G/02/detail/stars-4-5._V192253866_... width=\"64\" height=\"12\" border=\"0\" style=\"margin: 0; padding: 0;\"/>(51)<br /><br /><a href=\"http://www.amazon.co.uk/AllThingsAccessory%C2%AE-Sports-Running-Jogging-... new: </a> <strike>£7.99 - £9.99</strike> <font color=\"#990000\"><b>£4.99</b></font> <br /><br />(Visit the <a href=\"http://www.amazon.co.uk/gp/movers-and-shakers/sports/ref=pd_zg_rss_ms_sg... & Shakers in Sports & Outdoors</a> list for authoritative information on this product's current rank.)";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html