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.

Empfohlene Antworten

Veröffentlicht

Hi Forum,

ich habe einen String $myString = "Blah, Blub";

jetzt benötige ich einen Regulären Ausdruck der mir das Wort vor dem Komma zurückliefert.

wenn der string nur so aussieht, ginge da nicht explode?



$arr = explode("," $myString);

[/PHP]

dann ist in $arr[0] Blah und in $arr[1] Blub

ja danke für den Tipp!

Wer trotzdem noch eine Idee hat das ganze mit einem Regl. Ausdruck zu lösen soll sie bitte posten. :)

Hallo Naberius,

Der Aufbau von regulären Ausdrücken kannst du unter [1] nach lesen. Zu deinem Problem. Ich hab das mal als Perl-Script geschrieben:

$string="Blah, Blub";

$string =~ /([a-zA-Z]*)\,/;

print "$1\n";

Gruss

smokie

[1] http://www.home.fh-karlsruhe.de/~kuse0012/re/technik.html

Hi @ all!

zur PHP-Variante von oben:



$arr = explode("," $myString);

[/PHP]

[b]

dann ist in $arr[0] Blah und in $arr[1] Blub [/b]

geht nicht so ganz! So ist es richtig:

[PHP]

$arr = explode(", ",$myString);

Sonst mußt du von $arr[1] noch das Leerzeichen abschnipseln!

ja danke, also ich habe das jetzt mit split gelöst. Funktioniert ohne probleme.

Thx @ all!!!

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

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.