in reply to regex testing for ALL of the vowels in a scalar
That being said, though, this:
should do you pretty easily. Granted, it makes use of positive look-ahead which isn't strictly speaking "regular". The basic description of the regex is: there exists a place in the string (the beginning of the string, for example), after which exists an "a" AND after which exists an "e", etc./(?=.*a)(?=.*e)(?=.*i)(?=.*o)(?=.*u)/i
To do this with a true regular expression (and hence without lookahead assertions), you'd want to do it by essentially creating a list of all 5-factorial permutations of aeiou, and, over these permutations like so (written out kind of long-hand so that the idea should be transparent):
my @regex_pieces = (); foreach my $permutation (@permutations) { my @vowels = split //, $permutation; push @regex_pieces, join(".*", @vowels); } my $regex = qr/@{[join("|", @regex_pieces)]}/i;
------------ :Wq Not an editor command: Wq
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: regex testing for ALL of the vowels in a scalar
by ysth (Canon) on Feb 11, 2004 at 06:31 UTC | |
|
Re: Re: regex testing for ALL of the vowels in a scalar
by Roger (Parson) on Feb 11, 2004 at 05:59 UTC |