The only non-looping/non-map solution I could come up with is the code-assertion counting technique:
... # the array positions of the chars are viewed as 'bits' # Bits: 1 1 1 1 ==> decimal 15 my @a = qw'a r z x'; use re 'eval'; our $t = 1; # $t will be modified within the regex # build the regex, essentially: /a(?{...})| b(?{...}) | c(?{...}) ... + /g my $p = 0; # position count variable during initialization my $expr = join'|', map quotemeta($_)."(?{\$t|=".(1<<$p++)."})", @a; # initialize before run $t = 0; my $mystring = 'areqrtyz'; # evaluate the regex in list context () and # look after the result in $t (comma operator =>, ) print 'no match' if () = $mystring =~ /$expr/g, $t != 15; ...
Regards
mwa
In reply to Re: a regex which can detect if a string have all of some characters
by mwah
in thread a regex which can detect if a string have all of some characters
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |