Bob Showalter a écrit :
>
> If you want to match any of those characters (and no other) in any order,
> but at most once, here is a non-regex approach (not terribly efficient
> if you need to do it millions of times, but it works):
>
> use strict;
>
> my $key = 'cCdeEfGhiI'; # legal chars
>
> check('cCdE'); # match
> check('cCcE'); # no match
> check('xccE'); # no match
>
> sub check
> {
> my $val = shift;
>
> print "Testing $val: ";
> my %h = map { ($_ => 0) } split //, $key;
> for (split //, $val)
> {
> print("No match\n"), return
> unless exists $h{$_} && !$h{$_}++;
> }
> print "Match\n";
> }
Thanks for this Bob, but I forgot to say that :
- I need a regexp,
- I need a one-liner
- The order of characters doesn't matter
Sorry for this oversight, and thanks for your help.
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]