import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "line-height: 1.45;\\\"\\>(?P<value>.*)</h3><p class=3D|(?P<price>\\$[,\\d]*)<.p>";
final String string = "-family: 'Montserrat', sans-serif; text-decoration: none; color: #323232; f=\n"
+ "ont-weight: 500; font-size: 16px; line-height: 1.38;\">$144,900</p><h3 class=\n"
+ "=3D\"highlight-title\" style=3D\"margin: 0; margin-bottom: 6px; font-family: '=\n"
+ "Montserrat', sans-serif; text-decoration: none; color: #323232; font-weight=\n"
+ ": 500; font-size: 13px; line-height: 1.45;\">Value1</h3><p class=3D\"hi=\n"
+ "ghlight-description\" style=3D\"margin: 0; font-family: 'Montserrat', sans-se=\n"
+ "rif; text-decoration: none; color: #323232; font-weight: 500; font-size: 13=";
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