import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "href\\=\\\"([^\\\"]*)\\\"";
final String string = "<hr />\n"
+ "<ul>\n"
+ "<li><strong>خالد المشيقح:</strong></li>\n"
+ "</ul>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/01.mp3\">شرح التسهيل 1 </a></p>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/02.mp3\">شرح التسهيل 2 </a></p>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/03.mp3\">شرح التسهيل 3</a></p>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/04.mp3\">شرح التسهيل 4</a></p>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/05.mp3\">شرح التسهيل 5 </a></p>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/06.mp3\">شرح التسهيل 6</a></p>\n"
+ "<ul>\n"
+ "<li><strong>عبدالسلام الشويعر:</strong></li>\n"
+ "</ul>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/07.mp3\">شرح التسهيل 7</a></p>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/08.mp3\">شرح التسهيل 8 </a></p>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/09.mp3\">شرح التسهيل 9 </a></p>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/10.mp3\">شرح التسهيل 10</a></p>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/11.mp3\">شرح التسهيل 11 </a></p>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/12.mp3\">شرح التسهيل 12 </a></p>\n"
+ "<ul>\n"
+ "<li><strong>سامي الصقير:</strong></li>\n"
+ "</ul>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/13.mp3\">شرح التسهيل 13 </a></p>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/14.mp3\">شرح التسهيل 14 </a></p>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/15.mp3\">شرح التسهيل 15</a></p>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/16.mp3\">شرح التسهيل 16</a></p>\n"
+ "<p><a class=\"stealth download-pill\" href=\"https://archive.org/download/Kitab_Tasheel_fi_Fiqh/17.mp3\">شرح التسهيل 17 </a></p>\n"
+ "<hr />";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
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