in reply to Re^2: a regex to split this...
in thread a regex to split this...
Which had several problems.$username =~ /(cyc(\|\/)(.*?)/;
But not having coffee yet I corrected the split version instead.($username) = $ENV{REMOTE_USER} =~ /cyc(?:\\|\/)(.+)/; ($username) = $ENV{REMOTE_USER} =~ /cyc[\/\\](.+)/; # And to cleanup a little ($username) = $ENV{REMOTE_USER} =~ m{cyc(?:\\|/)(.+)}; ($username) = $ENV{REMOTE_USER} =~ m{cyc[/\\](.+)};
It's also worth nothing that split("\\|/","a|/b") does not work as one might think.
This happens because that pattern is actually looking for a literal '|/', as shown here:perl -e 'my ($a,$b) = split("\\|/","a/b"); print "a:$a\nb:$b\n"' a:a/b b:
perl -MO=Deparse -e 'my ($a,$b) = split("\\|/","a/b");' my($a, $b) = split(m[\|/], 'a/b', 3); perl -e 'my ($a,$b) = split("\\|/","a|/b"); print "a:$a\nb:$b\n"' a:a b:b
|
|---|