Like so ?
#!/usr/bin/perl -l # https://perlmonks.org/?node_id=1226058 use strict; use warnings; $_ = 'aabbcc'; my $len = length; my $inner = join ',', split //, tr///csr; my $glob = "{$inner}" x $len; my $re = "^(?=.{$len}\$)"; while( /./ ) { my $count = s/$&//g; $re .= "(?=(?:.*$&){$count})"; } $_ =~ $re and print for glob $glob;
Outputs the 90 valid permutations.
In reply to Re^3: Matching permutations with regex
by tybalt89
in thread Matching permutations with regex
by QM
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |