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.

PHP Regex Bilder austauschen

Empfohlene Antworten

Ich möchte gerne auf einer Seite mit einem regulären Ausdruck im HTML Quelltext Veränderungen vornehmen.

Es sollen Bild Tags veränder werden. Aus

<img src="images/logo.gif"> soll

<img src="http://www.disconow.de/images/logo.gif"> werden.

Dazu habe ich schon folgenden Ausdruck geschrieben:


function changeIMAGES($tmp) {
$tmp = preg_replace("=<[[:space:]]*img[[:space:]]*src\=\"*=isU","<img src=\"http://www.disconow.de/",$tmp);
return $tmp;}
[/php]

Funktioniert einwandfrei.

Wissen möchte ich aber jetzt, wie ich im Ausdruck überprüfen kann, ob schon ein http:// drinne steht, damit nicht sowas wie

http://www.disconow.de/http://www.disconow.de/images/logo.gif aus dem Tag wird.

Das gleiche Problem taucht dann auch noch auf, wenn die Bilder mit relativem Pfad (../../images.logo.gif) angegeben sind.

Dank im Voraus für die Hilfe.

Nachtrag:

das = nach src ist natürlich auch escaped, wenn ich den Beitrag bearbeite wird das auch angezeigt, komischer Weise aber nicht in der normalen Ansicht.

Admins: Liegt das am Board?

  • 2 Wochen später...

Ach ja, das


$tmp = preg_replace( "=(<img)(.*)(src\=\")(?!http)(.*)(\".*>)=siU","\\1\\2\\3$url\\4\\5", $tmp);
$tmp = preg_replace("=(<img)(.*)(src\=)(?!\")(?!http)(.*)(.*>)=siU","\\1\\2\\3$url\\4\\5",$tmp);
[/php]

wäre übrigens Ihr Preis gewesen. Da es keiner wußte musste ich mich wohl selber damit beschäftigen.

Wenigstens was dazugelernt :)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Konto

Navigation

Suchen

Suchen

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.