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] Reg Exp zu gierig

Empfohlene Antworten

Veröffentlicht

Hallo,

ich habe momentan ein Problem beim parsen einer XML Datei. Diese sieht wie folgt aus:


<row typeName="lala" groupID="266" typeID="3363">

    <description>Das möchte ich hier haben</description>

...

</row>

...

<row typeName="lulu" groupID="266" typeID="3732">

   <description>Das möchte ich nicht haben</description>

...

</row>

Die Punkte sollen zeigen, dass dazwischen noch weitere Attribute bzw. ganze Datensätze kommen. Nun habe ich folgenden regulären Ausdruck in preg_match_all angesetzt:

/typeName=\"(?<typeName>.+)\" groupID=\"(?<groupID>[0-9]+)\" typeID=\"(?<typeID>[0-9]+)\">.*<description>(?<description>.*?)</msU"

Das Ergebnis ist allerdings nicht das jeweilige description zum ersten Datensatz, sondern das letzte description was in dem XML vorkommt. Klingt für mich nach typischer Gierigkeit der Modifier. Allerdings sollte dies ja mit /U abgeschaltet sein. Selbst ohne /U und dann einem .*? vor dem description kommt das selbe Ergebnis hervor. Ich bin ein wenig am verzweifeln. Ich bin jetzt nicht der PHP Profi und ich weiss auch, dass man XML auch durch andere Funktionen parsen lassen kann, aber die helfen mir jetzt hier leider erstmal nicht.

Ich wäre wirklich für jede Idee dankbar.

Für xml Strukturen könnte ich das Modul "XML::Simple" empfehlen.. Damit wäre das problem zwar nur umgangen, aber ne Idee ist es auf jeden Fall..

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.