User since
2003-08-04
12208
Artikel
Admin1
aehmmm... wieso nicht einfach tr///?
@strings = qw(abc-def abc--def abc-d-ef abcdef ---abc--def--);
for my $string (@strings) {
print "<$string> " . ($string =~ tr/-// == 1 ? "ok" : "not ok");
}
=>
<abc-def> ok
<abc--def> not ok
<abc-d-ef> not ok
<abcdef> not ok
<---abc--def--> not ok
User since
2006-11-26
384
Artikel
BenutzerIn
Geht das nur mir so, oder versteht jemand den code von pq auch nicht? *g*
// Edit: Ok, nun verstehe ich. Nice geloest....\n\n
<!--EDIT|RPerl|1183298934-->
User since
2003-08-04
2036
Artikel
BenutzerIn
[quote=Guest,01.07.2007, 13:37]hi,
ich möchte eine if schleife ausführen wenn max 1 und min 1 "-" in einen string vorkommt... ich komm aber nicht auf den regex...
pls help[/quote]
if-Abfrage - denn if-Schleife gibts net...