String str = " <iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/UMUeWqnwmjs\" frameborder=\"0\" allowfullscreen></iframe>";
How to take the Src from this tag?
In such simple case you can use regexp (normally you should not use it for parsing html). The code below will look for src and retrieve it:
Matcher matcher = Pattern.compile("src=\"([^\"]+)\"").matcher(str);
matcher.find();
String src = matcher.group(1);
src will contain your src from iframe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With