Hallo,
habe z.b mehrere Dateien und möchte alle Nummern nach dem .html bist zu ersten unterstrich auslesen. Die Nummern haben alle verschiedene länge.
_dertest543_fauto_364467543.html
Ergebnis soll sein: 364467543
_testtest_test1556_test2_37543.html
Ergebnis soll sein: 37543
Regex auf HTML Dateien anwenden
Re: Regex auf HTML Dateien anwenden
Sollte sinngemäss funktionieren:
Code: Select all
ls *.html | grep _[0-9]. | sed -e "s/[0-9]*_[a-z_A-Z]*_//g"
02:32:12 21.12.2012 und dann sind Deine Probleme alle unwichtig.
Re: Regex auf HTML Dateien anwenden
Danke für die schnelle Antwort.ddm3ve wrote:Sollte sinngemäss funktionieren:Code: Select all
ls *.html | grep _[0-9]. | sed -e "s/[0-9]*_[a-z_A-Z]*_//g"
Funktioniert leider nicht richtig. Es sollte ohne sed sein, nur regex. Aus deinem Code habe ich das probiert s/[0-9]*_[a-z_A-Z]*_//g, geht auch nicht.
Re: Regex auf HTML Dateien anwenden
Klassiker Fall von WYGIWYAF.
Du hast bekommen, wonach Du gefragt hast.
Du hast bekommen, wonach Du gefragt hast.
02:32:12 21.12.2012 und dann sind Deine Probleme alle unwichtig.
Re: Regex auf HTML Dateien anwenden
Als Oneliner für die Shell:
Als reine RegEx:
Und für Dein mod_rewrite:
Code: Select all
find . -type f -name \*.html -print0 | xargs -0 -I % sed -e 's#_\([0-9]+\)\.html#\1#g' %
Code: Select all
s#_\([0-9]+\)\.html#\1#g
Code: Select all
_([0-9]+)\.html
PayPal.Me/JoeUser ● FreeBSD Remote Installation
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.