in reply to a regex which can detect if a string have all of some characters

The usual technique for testing "foundness" is to use a hash. Consider:

use strict; use warnings; my @a = ('a','r','z','x'); my $match = join '|', @a; my $mystring = 'areqrtyzx'; my %found; $found{$_}++ for grep /$match/, split '', $mystring; print "No match" unless @a == keys %found;

which also notices how many times each searched for item is found, although that may not be important depending on your application.


Perl is environmentally friendly - it saves trees
  • Comment on Re: a regex which can detect if a string have all of some characters
  • Download Code