Jeff 'japhy/Marillion' Pinyan a écrit :

> Someone else has already shown the general approach for ensuring a
> unique-character string:
> 
>   sub unique_characters {
>     $_[0] =~ /(.).*?\1/s ? 0 : 1
>   }
> 
> We can extrapolate upon this idea and test afterward that the string
> doesn't contain any unwanted characters:
> 
>   sub unique_char_set {
>     my ($str, $chars) = @_;
>     return 0 if $str =~ /[^\Q$chars\E]/;
>     return !($str =~ /(.).*?\1/s);
>   }

Thanks for your response guys. This is very useful.

In fact, since I needed a one liner (I forgot to say that) for a
regex-based dispatch table, I tried to convert that to :


($str !~ /(c|C|d|e|E|f|G|h|i|I|k|K|l|L|m|M|r|R|s|t|T|v|V|x|X).*?\1/s);

But this doesn't fail if unwanted characters are in.

So I am afraid that we'll arrive at (??{ ... }) 
What I am trying to do is some kind of shell. Command dispatching is
done via a hash containing "regex" => coderef style data. That's why I
am looking for a one--liner.

Thanks ! 
Michel.
-- 
Michel Blanc
Centre Multimédia Erasme/Parc d'activités innovantes
69930 Saint Clément-les-places
Tel : +33-(0)4-74-70-68-40 / Fax : +33-(0)4-74-70-68-40

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to