Ein Google-Apps-Skript erhält HTTP-Response-Inhaltstext. Der Auszug wie folgt.Javascript regex zum Extrahieren von Titel und iframe
<p style="text-align: left;"><span style="background-color: rgb(242, 195, 20);"><span style="color: rgb(192, 80, 77);">Disclaimer:</span></span><span style="background-color: rgb(255, 255, 255);">Please note,</span><a href="http://www.g00gl3.com"><span style="background-color: rgb(255, 255, 255);">http://www.g00gl3.com</span></a><span style="background-color: rgb(255, 255, 255);"> or </span><a href="http://www.g00gl3.com"><span style="background-color: rgb(255, 255, 255);">www.G00gl3.com</span></a><span style="background-color: rgb(255, 255, 255);"> is only video embedding websites. All of the videos found here come from 3rd party video hosting sites. We do not host any of the videos. Please contact to appropriate video hosting site for any video removal.</span></p>
<div style="text-align: center;"><strong><span style="background-color: rgb(255, 255, 255);">Dailymotion <br><br></span></strong></div>
<div style="text-align: center;"><iframe src="http://www.dailymotion.com/embed/video/foo1234567890bar? syndication=202279" width="640" height="360" frameborder="0"></iframe></div>
<div style="text-align: center;"><strong><span style="background-color: rgb(255, 255, 255);">Alternate Video <br><br></span></strong></div>
<div style="text-align: center;"><iframe src="http://hqq.tv/player/embed_player.php?vid=1234567890&autoplay=no" width="720" height="450" frameborder="0"></iframe></div>
Aus diesem Auszug müssen Titel (Dailymotion oder Alternate Video) und iframe extrahiert werden.
Nur iframe ist bereits abgestimmt.
/<iframe(.*)\/iframe>/g
Nun ist die erwartete ist
Dailymotion <br><br></span></strong></div>
<div style="text-align: center;"><iframe src="http://www.dailymotion.com/embed/video/foo1234567890bar? syndication=202279" width="640" height="360" frameborder="0"></iframe>
und
Alternate Video <br><br></span></strong></div>
<div style="text-align: center;"><iframe src="http://hqq.tv/player/embed_player.php?vid=1234567890&autoplay=no" width="720" height="450" frameborder="0"></iframe>
Kann jemand Hilfe regex schreiben nur oben zu holen.
Vielleicht könnten Sie einen DOM-Parser anstelle einer Regex verwenden. Regex verarbeitet verschachtelte XML nicht gut. –
Danke @TimBiegeleisen für die Antwort. Sie müssen prüfen, ob Google Apps Script über einen DOM-Parser verfügt. – Hsehdar