preg_replace div mit inhalt

Benjamin Rauer

Mitglied
Hallo Ihr lieben,
ich habe ein Problem beim beziehen von RSS-Feeds.
Bei einer Adresse wird immer das Amazon-Carousel mit eingebunden, welches ich verhindern will.
scheitere jedoch bein preg_replace.

Das <script> ansich wird bereits verhindert, jedoch bleibt das div mit dem Inhalt (Bild,Preis,Link).
$text = preg_replace("'<script[^>]*>.*?</script>'si", '', $text);

Code:
$text = rss->item;

$text = preg_replace('/(\<div\ class="aalb-product-carousel-unit"\>)(.+)(<\/div>)/si', '', $text);
        
$text = preg_replace('/<div class="aalb-product-carousel-unit">(.+?)<\/div>/s', '', $text);

beide und unzählige andere funktionierten bislang nicht :cry:
So wie ich das rausgelesen habe, handelt es sich um eine WP-Webseite mit dem entsprechenden Plugin.
 
Es ist schwer ein RegExp zu erstellen oder prüfen, wenn man keine Ahnung hat wie der Text aussieht.
Zeig mal ein Test-String den du hast und den passenden String den du haben willst.
 
$content = file_get_contents($newsfeed->link);
$rssDoc = new SimpleXmlElement($content);

$items = $rssDoc->channel->item;
$e_content = $item->children("content", true);
$text = (string)$e_content->encoded;


<div class="feed">

$text = 'Ganz normaler Content-text nachrichten etc --> bleibt bestehen!

Die komplette Div soll aus dem text entfernt werden!
Code:
<!--Section tag for iterating through the list of items-->
<div class="aalb-product-carousel-unit" id="aalb-B071GNJ4HC-B07NW5FXTK-B07Q3916WT-B07ZS7LC5H-B071X8P8F2-DE--ProductCarousel">
    <h2 class="aalb-pc-ad-header">Produkte von Amazon.de</h2>
    <!-- Title of the ad localized according to the marketplace picked from the AalbHeader tag-->
    <div class="aalb-pc-wrapper">
        <div class="aalb-pc-product-container">
            <ul class="aalb-pc-product-list"><!-- Section tag for beginning of information on one item --> <!-- Section tag for picking up information on attributes for the item -->
                <li class="aalb-pc-product">
                    <div class="aalb-pc-product-image">
                        <div class="aalb-pc-product-image-wrapper"><a href="https://www.amazon.de/BANDAI-NAMCO-Entertainment-Code-Vein/dp/B071GNJ4HC?psc=1&amp;SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=&amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B071GNJ4HC" title="Code Vein - [PlayStation 4]" target="_blank" rel="nofollow"> <!--Individual attributes are provided as variable tags as . Check documentation for list of supported variable tags.--> <img src="https://i1.wp.com/images-eu.ssl-images-amazon.com/images/I/61MHxk7VZqL._SL160_.jpg?w=640&amp;ssl=1" srcset="https://images-eu.ssl-images-amazon.com/images/I/61MHxk7VZqL.jpg" alt="Code Vein - [PlayStation 4]" data-recalc-dims="1" /> </a></div>
                        </div>
                        <div class="aalb-pc-product-details">
                        <div class="aalb-pc-product-title"><a href="https://www.amazon.de/BANDAI-NAMCO-Entertainment-Code-Vein/dp/B071GNJ4HC?psc=1&amp;SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=&amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B071GNJ4HC" title="Code Vein - [PlayStation 4]" target="_blank" rel="nofollow"> Code Vein - [PlayStation 4] </a></div>
                        <div class="aalb-pc-product-offer-price"><!-- The section tag for different marketplaces ensures localization of static text.  --> Preis: <span class="aalb-pc-product-offer-price-value">EUR 49,99</span></div>
                        <!-- The section tag ensures that prime icon is displayed only if it is available -->
                        <div class="aalb-pc-product-prime-icon"><i class="icon-prime-all"></i></div>
                    </div>
                </li>
                <!-- Section tag for beginning of information on one item --> <!-- Section tag for picking up information on attributes for the item -->
                <li class="aalb-pc-product">
                    <div class="aalb-pc-product-image">
                        <div class="aalb-pc-product-image-wrapper"><a href="https://www.amazon.de/Bandai-Namco-Entertainment-Germany-Eater/dp/B07K14LZ5G?SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=&amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B07K14LZ5G" title="God Eater 3" target="_blank" rel="nofollow"> <!--Individual attributes are provided as variable tags as . Check documentation for list of supported variable tags.--> <img src="https://i2.wp.com/images-eu.ssl-images-amazon.com/images/I/51G%2BjWQOADL._SL160_.jpg?w=640&amp;ssl=1" srcset="https://images-eu.ssl-images-amazon.com/images/I/51G%2BjWQOADL.jpg" alt="God Eater 3" data-recalc-dims="1" /> </a></div>
                    </div>
                    <div class="aalb-pc-product-details">
                        <div class="aalb-pc-product-title"><a href="https://www.amazon.de/Bandai-Namco-Entertainment-Germany-Eater/dp/B07K14LZ5G?SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=&amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B07K14LZ5G" title="God Eater 3" target="_blank" rel="nofollow"> God Eater 3 </a></div>
                        <div class="aalb-pc-product-offer-price"><!-- The section tag for different marketplaces ensures localization of static text.  --> Preis: <span class="aalb-pc-product-offer-price-value">EUR 19,99</span></div>
                        <!-- The section tag ensures that prime icon is displayed only if it is available -->
                        <div class="aalb-pc-product-prime-icon"><i class="icon-prime-all"></i></div>
                    </div>
                </li>

                viele wiederholungen
            </ul>
        </div>
    </div>
</div>';

</div>
 
Du willst den ganzen Text parsen. UInd welches Div soll verschwinden?
Und was willst du mit dem Code oberhalb des Code-Blocks in deinem Beitrag aussagen?

Zu deiner Info, ich kenne den Feed nicht. Ich habe keine Ahnung was du bekommst und was man damit machen kann. Aber ich habe sehr viel Ahnung von Regulären Ausdrücken.

Daum nochmals
  1. Text der geparst werden soll. Also der Text, der an preg_replace () übergeben wird. Ich nehme mal an, es ist der grosse HTML-Plock
    zB: "Die ID ist #1234."
  2. Gewünschtes gefundener Teil als Beispiel
    zB: "#1234"
  3. Beispiel für den ersetzen Teil
    zB: "ID:1234"
 
Das ist der Komplette Text der geparst wird !

HTML:
<p><img src="https://i1.wp.com/www.topgamingnews.de/wp-content/uploads/2018/04/code-vein-800x450.jpg?resize=350,350&amp;ssl=1" class="webfeedsFeaturedVisual wp-post-image" alt="" style="display: block; margin-bottom: 5px; clear: both; max-width: 100%;" link_thumbnail="" srcset="https://i1.wp.com/www.topgamingnews.de/wp-content/uploads/2018/04/code-vein-800x450.jpg?resize=350,350&amp;ssl=1 350w, https://i1.wp.com/www.topgamingnews.de/wp-content/uploads/2018/04/code-vein-800x450.jpg?zoom=2&amp;resize=350,350&amp;ssl=1 700w" sizes="(max-width: 350px) 100vw, 350px" data-attachment-id="7079" data-permalink="https://www.topgamingnews.de/2018/04/19/neue-informationen-und-features-fuer-code-vein/code-vein-800x450/" data-orig-file="https://i1.wp.com/www.topgamingnews.de/wp-content/uploads/2018/04/code-vein-800x450.jpg?fit=800,450&amp;ssl=1" data-orig-size="800,450" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="code-vein-800×450" data-image-description="" data-medium-file="https://i1.wp.com/www.topgamingnews.de/wp-content/uploads/2018/04/code-vein-800x450.jpg?fit=350,197&amp;ssl=1" data-large-file="https://i1.wp.com/www.topgamingnews.de/wp-content/uploads/2018/04/code-vein-800x450.jpg?fit=640,360&amp;ssl=1" width="350" height="350" /></p>

<p>Sollte dieser Beitrag/Bilder/Links nicht richtig angezeigt werden, dann klicken Sie bitte hier: <a rel="nofollow" href="CODE VEIN - Tauche ab in die Welt von Vein in der ab sofort verfügbaren Demo!">CODE VEIN – Tauche ab in die Welt von Vein in der ab sofort verfügbaren Demo!</a></p>

<p><strong>Kennst du schon unsere App?</strong> Sie ist kostenlos für alle <a href="Gaming News - Videospiele Nachrichten - Apps on Google Play" target="_blank" rel="noopener"><strong>Android</strong></a> und <a href="‎Gaming News" target="_blank" rel="noopener"><strong>iOS</strong></a> Geräte verfügbar!</p>

<p>BANDAI NAMCO Entertainment gibt heute bekannt, dass die Demoversion von <em><strong>CODE VEIN</strong></em> ab sofort auf PC via STEAM verfügbar ist.</p>

<p><strong>Die Demo</strong> ermöglicht es den SpielerInnen, mit dem Charakter-Creator zu experimentieren, ihren eigenen Wiedergänger zum Leben zu erwecken und ihre Fähigkeiten auf die Probe zu stellen, während sie einen frühen Abschnitt des Spiels allein oder mit einem Freund im Koop-Modus erkunden. Darüber hinaus ist die Sonderzone, Depths: Town of Sacrifice, ebenfalls zugänglich, so dass die SpielerInnen gegen zuvor besiegte Bosse kämpfen können, um an Dunst, neue Waffen und Material zu gelangen.</p>

<p>Alle in der Demo erstellten Charaktere sind auf das Hauptspiel übertragbar.</p>

<p><em><strong>CODE VEIN</strong></em> spielt in der gnadenlosen Welt von Vein und bietet eine umfangreiche, personalisierbare Action-RPG-Erfahrung. Das Spiel ist für PlayStation 4, Xbox One und PC verfügbar.</p>


<p><img src="https://ir-de.amazon-adsystem.com/e/ir?t=amp;l=alb&amp;o=3&amp;a=B071GNJ4HC" alt="" style="position: fixed !important; bottom: -1px !important; right: -1px !important; border: none !important; margin: 0px !important;" width="1px" height="1px" /><img src="https://ir-de.amazon-adsystem.com/e/ir?t=amp;l=alb&amp;o=3&amp;a=B07K14LZ5G" alt="" style="position: fixed !important; bottom: -1px !important; right: -1px !important; border: none !important; margin: 0px !important;" width="1px" height="1px" /><img src="https://ir-de.amazon-adsystem.com/e/ir?t=amp;l=alb&amp;o=3&amp;a=B01MTX8L70" alt="" style="position: fixed !important; bottom: -1px !important; right: -1px !important; border: none !important; margin: 0px !important;" width="1px" height="1px" /><img src="https://ir-de.amazon-adsystem.com/e/ir?t=amp;l=alb&amp;o=3&amp;a=B07DPJWRX8" alt="" style="position: fixed !important; bottom: -1px !important; right: -1px !important; border: none !important; margin: 0px !important;" width="1px" height="1px" /><img src="https://ir-de.amazon-adsystem.com/e/ir?t=amp;l=alb&amp;o=3&amp;a=B07YGH6DRD" alt="" style="position: fixed !important; bottom: -1px !important; right: -1px !important; border: none !important; margin: 0px !important;" width="1px" height="1px" /><img src="https://ir-de.amazon-adsystem.com/e/ir?t=amp;l=alb&amp;o=3&amp;a=B07NW5FXTK" alt="" style="position: fixed !important; bottom: -1px !important; right: -1px !important; border: none !important; margin: 0px !important;" width="1px" height="1px" /><img src="https://ir-de.amazon-adsystem.com/e/ir?t=amp;l=alb&amp;o=3&amp;a=B07Q3916WT" alt="" style="position: fixed !important; bottom: -1px !important; right: -1px !important; border: none !important; margin: 0px !important;" width="1px" height="1px" /><img src="https://ir-de.amazon-adsystem.com/e/ir?t=amp;l=alb&amp;o=3&amp;a=B07ZS7LC5H" alt="" style="position: fixed !important; bottom: -1px !important; right: -1px !important; border: none !important; margin: 0px !important;" width="1px" height="1px" /><img src="https://ir-de.amazon-adsystem.com/e/ir?t=amp;l=alb&amp;o=3&amp;a=B071X8P8F2" alt="" style="position: fixed !important; bottom: -1px !important; right: -1px !important; border: none !important; margin: 0px !important;" width="1px" height="1px" /></p>


<!-- Ad Template with Carousel Layout-->

<p></p>

<!--Section tag for iterating through the list of items-->

AB HIER ALLES ENTFERNEN

Code:
<div class="aalb-product-carousel-unit" id="aalb-B071GNJ4HC-B07K14LZ5G-B01MTX8L70-B07DPJWRX8-B07YGH6DRD-B07NW5FXTK-B07Q3916WT-B07ZS7LC5H-B071X8P8F2-DE--ProductCarousel">

<h2 class="aalb-pc-ad-header">Produkte von Amazon.de</h2>

<!-- Title of the ad localized according to the marketplace picked from the AalbHeader tag-->

<div class="aalb-pc-wrapper">

<div class="aalb-pc-product-container">

<ul class="aalb-pc-product-list"><!-- Section tag for beginning of information on one item --> <!-- Section tag for picking up information on attributes for the item -->

<li class="aalb-pc-product">

<div class="aalb-pc-product-image">

<div class="aalb-pc-product-image-wrapper"><a href="https://www.amazon.de/BANDAI-NAMCO-Entertainment-Code-Vein/dp/B071GNJ4HC?psc=1&amp;SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B071GNJ4HC" title="Code Vein - [PlayStation 4]" target="_blank" rel="nofollow"> <!--Individual attributes are provided as variable tags as . Check documentation for list of supported variable tags.--> <img src="https://i1.wp.com/images-eu.ssl-images-amazon.com/images/I/61MHxk7VZqL._SL160_.jpg?w=640&amp;ssl=1" srcset="https://images-eu.ssl-images-amazon.com/images/I/61MHxk7VZqL.jpg" alt="Code Vein - [PlayStation 4]" data-recalc-dims="1" /> </a></div>

</div>

<div class="aalb-pc-product-details">

<div class="aalb-pc-product-title"><a href="https://www.amazon.de/BANDAI-NAMCO-Entertainment-Code-Vein/dp/B071GNJ4HC?psc=1&amp;SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B071GNJ4HC" title="Code Vein - [PlayStation 4]" target="_blank" rel="nofollow"> Code Vein - [PlayStation 4] </a></div>

<div class="aalb-pc-product-offer-price"><!-- The section tag for different marketplaces ensures localization of static text.  --> Preis: <span class="aalb-pc-product-offer-price-value">EUR 49,99</span></div>

<!-- The section tag ensures that prime icon is displayed only if it is available -->

<div class="aalb-pc-product-prime-icon"><i class="icon-prime-all"></i></div>

</div>

</li>

<!-- Section tag for beginning of information on one item --> <!-- Section tag for picking up information on attributes for the item -->

<li class="aalb-pc-product">

<div class="aalb-pc-product-image">

<div class="aalb-pc-product-image-wrapper"><a href="https://www.amazon.de/Bandai-Namco-Entertainment-Germany-Eater/dp/B07K14LZ5G?SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B07K14LZ5G" title="God Eater 3" target="_blank" rel="nofollow"> <!--Individual attributes are provided as variable tags as . Check documentation for list of supported variable tags.--> <img src="https://i2.wp.com/images-eu.ssl-images-amazon.com/images/I/51G%2BjWQOADL._SL160_.jpg?w=640&amp;ssl=1" srcset="https://images-eu.ssl-images-amazon.com/images/I/51G%2BjWQOADL.jpg" alt="God Eater 3" data-recalc-dims="1" /> </a></div>

</div>

<div class="aalb-pc-product-details">

<div class="aalb-pc-product-title"><a href="https://www.amazon.de/Bandai-Namco-Entertainment-Germany-Eater/dp/B07K14LZ5G?SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B07K14LZ5G" title="God Eater 3" target="_blank" rel="nofollow"> God Eater 3 </a></div>

<div class="aalb-pc-product-offer-price"><!-- The section tag for different marketplaces ensures localization of static text.  --> Preis: <span class="aalb-pc-product-offer-price-value">EUR 19,99</span></div>

<!-- The section tag ensures that prime icon is displayed only if it is available -->

<div class="aalb-pc-product-prime-icon"><i class="icon-prime-all"></i></div>

</div>

</li>

<!-- Section tag for beginning of information on one item --> <!-- Section tag for picking up information on attributes for the item -->

<li class="aalb-pc-product">

<div class="aalb-pc-product-image">

<div class="aalb-pc-product-image-wrapper"><a href="https://www.amazon.de/Last-Us-Part-II-Standard/dp/B01MTX8L70?psc=1&amp;SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B01MTX8L70" title="The Last of Us Part II - Standard Edition" target="_blank" rel="nofollow"> <!--Individual attributes are provided as variable tags as . Check documentation for list of supported variable tags.--> <img src="https://i0.wp.com/images-eu.ssl-images-amazon.com/images/I/41bCOOjy3oL._SL160_.jpg?w=640&amp;ssl=1" srcset="https://images-eu.ssl-images-amazon.com/images/I/41bCOOjy3oL.jpg" alt="The Last of Us Part II - Standard Edition" data-recalc-dims="1" /> </a></div>

</div>

<div class="aalb-pc-product-details">

<div class="aalb-pc-product-title"><a href="https://www.amazon.de/Last-Us-Part-II-Standard/dp/B01MTX8L70?psc=1&amp;SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B01MTX8L70" title="The Last of Us Part II - Standard Edition" target="_blank" rel="nofollow"> The Last of Us Part II - Standard Edition </a></div>

<div class="aalb-pc-product-offer-price"><!-- The section tag for different marketplaces ensures localization of static text.  --> Preis: <span class="aalb-pc-product-offer-price-value">EUR 69,99</span></div>

</div>

</li>

<!-- Section tag for beginning of information on one item --> <!-- Section tag for picking up information on attributes for the item -->

<li class="aalb-pc-product">

<div class="aalb-pc-product-image">

<div class="aalb-pc-product-image-wrapper"><a href="https://www.amazon.de/Ghost-of-Tsushima-PlayStation-4/dp/B07DPJWRX8?SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B07DPJWRX8" title="Ghost of Tsushima [PlayStation 4]" target="_blank" rel="nofollow"> <!--Individual attributes are provided as variable tags as . Check documentation for list of supported variable tags.--> <img src="https://i0.wp.com/images-eu.ssl-images-amazon.com/images/I/41AcezmVheL._SL160_.jpg?w=640&amp;ssl=1" srcset="https://images-eu.ssl-images-amazon.com/images/I/41AcezmVheL.jpg" alt="Ghost of Tsushima [PlayStation 4]" data-recalc-dims="1" /> </a></div>

</div>

<div class="aalb-pc-product-details">

<div class="aalb-pc-product-title"><a href="https://www.amazon.de/Ghost-of-Tsushima-PlayStation-4/dp/B07DPJWRX8?SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B07DPJWRX8" title="Ghost of Tsushima [PlayStation 4]" target="_blank" rel="nofollow"> Ghost of Tsushima [PlayStation 4] </a></div>

<div class="aalb-pc-product-offer-price"><!-- The section tag for different marketplaces ensures localization of static text.  --> Preis: <span class="aalb-pc-product-offer-price-value">EUR 70,77</span></div>

<!-- The section tag ensures that prime icon is displayed only if it is available -->

<div class="aalb-pc-product-prime-icon"><i class="icon-prime-all"></i></div>

</div>

</li>

<!-- Section tag for beginning of information on one item --> <!-- Section tag for picking up information on attributes for the item -->

<li class="aalb-pc-product">

<div class="aalb-pc-product-image">

<div class="aalb-pc-product-image-wrapper"><a href="https://www.amazon.de/PlayStation-Pro-Death-Stranding-Limited/dp/B07YGH6DRD?psc=1&amp;SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B07YGH6DRD" title="PlayStation 4  Pro Death Stranding Limited Edition - Konsole (1TB, schwarz, Pro)" target="_blank" rel="nofollow"> <!--Individual attributes are provided as variable tags as . Check documentation for list of supported variable tags.--> <img src="https://i1.wp.com/images-eu.ssl-images-amazon.com/images/I/51ibdqUY3XL._SL160_.jpg?w=640&amp;ssl=1" srcset="https://images-eu.ssl-images-amazon.com/images/I/51ibdqUY3XL.jpg" alt="PlayStation 4  Pro Death Stranding Limited Edition - Konsole (1TB, schwarz, Pro)" data-recalc-dims="1" /> </a></div>

</div>

<div class="aalb-pc-product-details">

<div class="aalb-pc-product-title"><a href="https://www.amazon.de/PlayStation-Pro-Death-Stranding-Limited/dp/B07YGH6DRD?psc=1&amp;SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B07YGH6DRD" title="PlayStation 4  Pro Death Stranding Limited Edition - Konsole (1TB, schwarz, Pro)" target="_blank" rel="nofollow"> PlayStation 4 Pro Death Stranding Limited Edition - Konsole (1TB, schwarz, Pro) </a></div>

<div class="aalb-pc-product-offer-price"><!-- The section tag for different marketplaces ensures localization of static text.  --> Preis: <span class="aalb-pc-product-offer-price-value">EUR 479,00</span></div>

<!-- The section tag ensures that prime icon is displayed only if it is available -->

<div class="aalb-pc-product-prime-icon"><i class="icon-prime-all"></i></div>

</div>

</li>

<!-- Section tag for beginning of information on one item --> <!-- Section tag for picking up information on attributes for the item -->

<li class="aalb-pc-product">

<div class="aalb-pc-product-image">

<div class="aalb-pc-product-image-wrapper"><a href="https://www.amazon.de/Legend-Zelda-Awakening-Nintendo-Switch/dp/B07NW5FXTK?psc=1&amp;SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B07NW5FXTK" title="The Legend of Zelda: Link's Awakening [Nintendo Switch]" target="_blank" rel="nofollow"> <!--Individual attributes are provided as variable tags as . Check documentation for list of supported variable tags.--> <img src="https://i0.wp.com/images-eu.ssl-images-amazon.com/images/I/512Jxh6sy0L._SL160_.jpg?w=640&amp;ssl=1" srcset="https://images-eu.ssl-images-amazon.com/images/I/512Jxh6sy0L.jpg" alt="The Legend of Zelda: Link's Awakening [Nintendo Switch]" data-recalc-dims="1" /> </a></div>

</div>

<div class="aalb-pc-product-details">

<div class="aalb-pc-product-title"><a href="https://www.amazon.de/Legend-Zelda-Awakening-Nintendo-Switch/dp/B07NW5FXTK?psc=1&amp;SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B07NW5FXTK" title="The Legend of Zelda: Link's Awakening [Nintendo Switch]" target="_blank" rel="nofollow"> The Legend of Zelda: Link's Awakening [Nintendo Switch] </a></div>

<div class="aalb-pc-product-offer-price"><!-- The section tag for different marketplaces ensures localization of static text.  --> Preis: <span class="aalb-pc-product-offer-price-value">EUR 47,99</span></div>

<!-- The section tag ensures that prime icon is displayed only if it is available -->

<div class="aalb-pc-product-prime-icon"><i class="icon-prime-all"></i></div>

</div>

</li>

<!-- Section tag for beginning of information on one item --> <!-- Section tag for picking up information on attributes for the item -->

<li class="aalb-pc-product">

<div class="aalb-pc-product-image">

<div class="aalb-pc-product-image-wrapper"><a href="https://www.amazon.de/Borderlands-3-Standard-Edition-PS4/dp/B07Q3916WT?SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B07Q3916WT" title="Borderlands 3 Standard Edition - [PS4]" target="_blank" rel="nofollow"> <!--Individual attributes are provided as variable tags as . Check documentation for list of supported variable tags.--> <img src="https://i0.wp.com/images-eu.ssl-images-amazon.com/images/I/61fvM%2BtEigL._SL160_.jpg?w=640&amp;ssl=1" srcset="https://images-eu.ssl-images-amazon.com/images/I/61fvM%2BtEigL.jpg" alt="Borderlands 3 Standard Edition - [PS4]" data-recalc-dims="1" /> </a></div>

</div>

<div class="aalb-pc-product-details">

<div class="aalb-pc-product-title"><a href="https://www.amazon.de/Borderlands-3-Standard-Edition-PS4/dp/B07Q3916WT?SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B07Q3916WT" title="Borderlands 3 Standard Edition - [PS4]" target="_blank" rel="nofollow"> Borderlands 3 Standard Edition - [PS4] </a></div>

<div class="aalb-pc-product-offer-price"><!-- The section tag for different marketplaces ensures localization of static text.  --> Preis: <span class="aalb-pc-product-offer-price-value">EUR 29,75</span></div>

</div>

</li>

<!-- Section tag for beginning of information on one item --> <!-- Section tag for picking up information on attributes for the item -->

<li class="aalb-pc-product">

<div class="aalb-pc-product-image">

<div class="aalb-pc-product-image-wrapper"><a href="https://www.amazon.de/Nioh-2-Standard-PlayStation-4/dp/B07ZS7LC5H?psc=1&amp;SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B07ZS7LC5H" title="Nioh 2 - Standard Edition [PlayStation 4]" target="_blank" rel="nofollow"> <!--Individual attributes are provided as variable tags as . Check documentation for list of supported variable tags.--> <img src="https://i1.wp.com/images-eu.ssl-images-amazon.com/images/I/51Gd0WKxnfL._SL160_.jpg?w=640&amp;ssl=1" srcset="https://images-eu.ssl-images-amazon.com/images/I/51Gd0WKxnfL.jpg" alt="Nioh 2 - Standard Edition [PlayStation 4]" data-recalc-dims="1" /> </a></div>

</div>

<div class="aalb-pc-product-details">

<div class="aalb-pc-product-title"><a href="https://www.amazon.de/Nioh-2-Standard-PlayStation-4/dp/B07ZS7LC5H?psc=1&amp;SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B07ZS7LC5H" title="Nioh 2 - Standard Edition [PlayStation 4]" target="_blank" rel="nofollow"> Nioh 2 - Standard Edition [PlayStation 4] </a></div>

<div class="aalb-pc-product-offer-price"><!-- The section tag for different marketplaces ensures localization of static text.  --> Preis: <span class="aalb-pc-product-offer-price-value">EUR 69,99</span></div>

<!-- The section tag ensures that prime icon is displayed only if it is available -->

<div class="aalb-pc-product-prime-icon"><i class="icon-prime-all"></i></div>

</div>

</li>

<!-- Section tag for beginning of information on one item --> <!-- Section tag for picking up information on attributes for the item -->

<li class="aalb-pc-product">

<div class="aalb-pc-product-image">

<div class="aalb-pc-product-image-wrapper"><a href="https://www.amazon.de/Code-Vein/dp/B071X8P8F2?SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B071X8P8F2" title="Code Vein" target="_blank" rel="nofollow"> <!--Individual attributes are provided as variable tags as . Check documentation for list of supported variable tags.--> <img srcset="" alt="Code Vein" /> </a></div>

</div>

<div class="aalb-pc-product-details">

<div class="aalb-pc-product-title"><a href="https://www.amazon.de/Code-Vein/dp/B071X8P8F2?SubscriptionId=AKIAJOXGEENI3ELTLRPQ&amp;tag=amp;linkCode=alb&amp;camp=2025&amp;creative=165953&amp;creativeASIN=B071X8P8F2" title="Code Vein" target="_blank" rel="nofollow"> Code Vein </a></div>

<div class="aalb-pc-product-offer-price"><!-- The section tag for different marketplaces ensures localization of static text.  --> Preis: <span class="aalb-pc-product-offer-price-value">Derzeit nicht verfügbar</span></div>

</div>

</li>

</ul>

</div>

</div>

<a class="aalb-pc-btn-prev">‹</a> <a class="aalb-pc-btn-next">›</a></div>
 
Zuletzt bearbeitet:
Hä? Der gesuchte Text (Dein 2ter Text) existiert im Kompletten Text (erster Text) NICHT. Da ist nicht mal ein DIV drin.
Wo soll was ausgelesen und ersetzt werden? Waren meine Rückfragen so unklar?

Sorry, ich bin raus. Ich gebs auf, habe anderes zu tun als Informationen zu erbetteln um helfen zu dürfen.
 
DEIN ERNST!!
Ob ich dir das JETZT Soooooo


Und Sage, das der komplette '<div class="aalb-product-carousel-unit">' container mit Inhalt gelöscht werden soll!!!!!!

oder es vereinfacht aufliste und schreibe ab AB HIER ALLES ENTFERNEN das ergebnis bleibt das selbe.

meine frage war:::::: wie kann ich einen kompletten div aus einem String entfernen.
habe es bereits wie oben erwähnt mit
preg_replace('/(\<div\ class="aalb-product-carousel-unit"\>)(.+)(<\/div>)/si', '', $text);

ohne erfolg versucht.
 
Zuletzt bearbeitet:
nicht schön aber so gehts:
Code:
$text = preg_replace('#<div\b[^>]+\bclass\s*=\s*[\'\"]aalb-product-carousel-unit[\'\"][^>]*>([\s\S]*?)</div>#', ' ', $text);
$text = preg_replace('/(\<a\ class="aalb-pc-btn-prev"\>)(.+)(<\/a>)/si', '', $text);
$text = preg_replace('/(\<div\ class="aalb-pc-product-prime-icon"\>)(.+)(<\/div>)/si', '', $text);
$text = preg_replace('/(\<div\ class="aalb-pc-product"\>)(.+)(<\/div>)/si', '', $text);
$text = preg_replace('/(\<div\ class="aalb-pc-product-details"\>)(.+)(<\/div>)/si', '', $text);
$text = preg_replace('/(\<div\ class="aalb-pc-product-offer-price"\>)(.+)(<\/div>)/si', '', $text);

löscht alle div einzelnd und das Carusell ist weg
 
@Benjamin Rauer , ich kann @Yaslaw scho verstehen , ich muß aber auch sagen das es schwer zu verstehen wahr.
Normalerweise postet man den ganzen Code und zeigt dann was man haben will , so wie du es in post #8 gemacht hast.
Aber du hast ja jetzt eine Lösung gefunden.
Ich denke mit Regex könnte es vieleicht einfacher ( bzw kürzerer Code werden ).
Mfg Basti
 
Zurück