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.

Perl: Zeichen aus string löschen

Empfohlene Antworten

Veröffentlicht

Tach allerseits,

ich bin auf der suche nach einer Lösung zu meinem Problem :D .

Also ich hab in einer Variable einen kompletten Pfad.

z.B. C:\test\asdf\test.pj

und will alles hinter dem letzten '\' entfernen.

so C:\test\asdf\

um dann nurnoch das Verzeichniss zu haben.

Habt ihr vorschläge?

Danke

Hi,

also ich weiß nicht wie das in Perl geht aber ich habe mal dafür ne kleine Schleife für (ANSI) C geschrieben.

pfad ist logischer weise der ganze eingelesene Pfad

len ist in dem Fall der Pointer vom String


len = strlen(pfad);

for (;

{

	if (pfad[len] != '\\')

		len = len - 1;

	if (pfad[len] == '\\')

		break;

}

len = len + 1;

pfad[len] = '\0';

[/code]

[b]zum Code:[/b]

len wird runtergezählt bis ein \ kommt und zählt um eins wieder hoch und setzt an die stellen ein EOF.

Hoffe konnte helfen...

cYa DePlague

Servus Fafo.

Das kannst du am besten mit Regular Expressions lösen. Das beste ist, wenn du dir das nochmal anschaust, denn das ist ja das Mächtige an Perl ;)

Aber hier die Lösung:

$x = 'C:\test\asdf\test.pj';

($y) = ($x =~ /((.*)\\)/);

print $y;

Gruß

alligator

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.