> -----Original Message-----
> From: Michel Blanc [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 22, 2001 10:58 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: Regex help
> 
> 
> Jeff 'japhy/Marillion' Pinyan a écrit :
> > 
> 
> > I think you mean "if a letter has already matched, it CAN'T 
> repeat again
> > in the string" -- meaning, each character must be unique.
> 
> Yes, that's right.
> 
> > It's not a simple task without a complex regex assertion, 
> (??{ ... }).
> > 
> > I can provide a solution, but I cannot guarantee it will be easy to
> > understand once explained.
> 
> I already spend a lot of energy on your JAPHs :)
> Thank you for spending time on this.
> When you'll send me your solution, I'll come back and tell you if I
> understand what you did !

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";
 }

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

Reply via email to