Schrift
Wiki:Tipp zum Debugging: use Data::Dumper; local $Data::Dumper::Useqq = 1; print Dumper \@var;
[thread]6186[/thread]

if und regex: schöner schreiben-..



<< |< 1 2 >| >> 14 Einträge, 2 Seiten
steinwolf
 2004-04-10 13:31
#81484 #81484
User since
2003-08-04
367 Artikel
BenutzerIn
[default_avatar]
Hi

if (-f $_ && $_=~/jpg$/ || $_=~/JPG$/)

kann ich das irgendwie kürzen? Zum Beispiel dass die regex nicht case sensitive ist?


mfg stein
"Did you know? You can use your old motor oil to fertilize your lawn." - Blinkster - Professionelles EDV Forum
format_c
 2004-04-10 13:35
#81485 #81485
User since
2003-08-04
1706 Artikel
HausmeisterIn
[Homepage] [default_avatar]
if (-f && /jpg$/i)

Gruß Alex
esskar
 2004-04-10 13:36
#81486 #81486
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
[quote=format_c,10.04.2004, 11:35]if (-f && /jpg$/i)

Gruß Alex[/quote]
bin für das m

also

if (-f && m/jpg$/i)
steinwolf
 2004-04-10 13:36
#81487 #81487
User since
2003-08-04
367 Artikel
BenutzerIn
[default_avatar]
ach ja, "i"

:D

danke format_c
"Did you know? You can use your old motor oil to fertilize your lawn." - Blinkster - Professionelles EDV Forum
steinwolf
 2004-04-10 13:38
#81488 #81488
User since
2003-08-04
367 Artikel
BenutzerIn
[default_avatar]
najut, wie kann ich nun in einer einzigen regex mehrere formate abfragen, also nicht nur jpg sondern auch jpeg, gif etc..
ist das überhaupt effektiv in einer regex oder muss ich da kombinieren (&&)?

edit: ich glaub ich habs schon
if (-f && m/[jpg gif bmp jpeg]$/i)\n\n

<!--EDIT|steinwolf|1081590058-->
"Did you know? You can use your old motor oil to fertilize your lawn." - Blinkster - Professionelles EDV Forum
format_c
 2004-04-10 13:41
#81489 #81489
User since
2003-08-04
1706 Artikel
HausmeisterIn
[Homepage] [default_avatar]
if (-f && /(?:jpg|jpeg|gif)$/i)

@esskar: ich warum m wenns auch ohne geht solange man / verwendet.

Gruß Alex
format_c
 2004-04-10 13:44
#81490 #81490
User since
2003-08-04
1706 Artikel
HausmeisterIn
[Homepage] [default_avatar]
@Steinwolf: Also dein Regex matcht alles wo einer der Buchstabe am ende Steht.
Zum beispiel würde test.j auch matchen.

Gruß Alex\n\n

<!--EDIT|format_c|1081590320-->
steinwolf
 2004-04-10 13:49
#81491 #81491
User since
2003-08-04
367 Artikel
BenutzerIn
[default_avatar]
ok, dann nehm ich deinen lösungsansatz,
danke für die hilfe :)
"Did you know? You can use your old motor oil to fertilize your lawn." - Blinkster - Professionelles EDV Forum
esskar
 2004-04-10 13:49
#81492 #81492
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
weil es so
Code: (dl )
if (-f && !(?:jpg|jpeg|gif)$!i)

nicht mehr gehen würde. da brauchst du dann das m.
Vielleicht ist es auch nur Gewohnheit!
format_c
 2004-04-10 13:50
#81493 #81493
User since
2003-08-04
1706 Artikel
HausmeisterIn
[Homepage] [default_avatar]
[quote=format_c,10.04.2004, 11:41]...
@esskar: ich warum m wenns auch ohne geht solange man / verwendet.
...[/quote]
Dieser Tatsache war ich mir bewusst.

Gruß Alex
<< |< 1 2 >| >> 14 Einträge, 2 Seiten



View all threads created 2004-04-10 13:31.