import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "width=\\\"([^\"]*)\\\"";
final String string = "<iframe src=\"https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2599.1307619404383!2d8.161241415866494!3d49.34967357394241!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x479648efa698cf4d%3A0xb771157caba628a8!2sMennoniten%20Branchweilerhof!5e0!3m2!1sde!2sde!4v1590230850775!5m2!1sde!2sde\" width=\"600\" height=\"450\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\" aria-hidden=\"false\" tabindex=\"0\" style=\"border: 0px;\"></iframe>";
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