Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ereg() - Links filtern

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

Ich brauche einen regulären Ausdruck um den inhalt aus einem "href" auszufiltern. Nun kenn ich mich aber mit regex nicht aus.

Ich habe mir mal einen Ansatz aus einem anderen Thread zusammengestellt, funktioniert aber nicht!


echo eregi("[^<a.+?href=\"?.*\"?.+?/?>]",$text,$myA);
echo sizeof($myA);
[/PHP]

Kann mir mal einer nen Ansatz geben?

gruss

markus

  • Autor

So - hab selbst eine Lösung gefunden, die bis jetzt ganz gut funktioniert.


$text = "<a href=\"linkurl.php\">linktext</a>
<a href=\"linkurl2.php\"><img src=\"lll.gif\"></a>
<a href=\"Linkooourl3.php\">linktext3</a>
<a href=\"Linkooourl4.php\">linktext4</a>
lökäöl<a href=\"linkurl5.php\">linktext5</a>
<a href=\"linkurl6.php\">linktext6</a>
<a href=\"linkurl7.php\">linktext7</a>
<a href=\"linkurl8.php\">linktext8</a>
<a href=\"linkurl9.php\">linktext9</a>";

preg_match_all("/href=\"(.*?)\"/", $text, $text2);

$max=20;
for ($i=0; $i<$max; $i++)
{
$p = preg_split("[>]", $text2[1][$i]);
echo $p[0]." - ".$p[1]."<br>";
}
[/PHP]

ok - das funktioniert so weit, allerdings nur, wenn der Link in " eingeschlossen ist. Was ist wenn aber der Link von ' eingeschlossen ist.

ok - das funktioniert so weit, allerdings nur, wenn der Link in " eingeschlossen ist. Was ist wenn aber der Link von ' eingeschlossen ist.

Dann nimmst du statt Match auf " einen Match auf ["']?


preg_match_all("/href=[\'\"](.*?)[\'\"]/", $text, $text2);
[/php]

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.