Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Matching permutations with regex

by QM (Parson)
on Nov 20, 2018 at 11:29 UTC ( [id://1226058]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    @x = glob('{a,b,c}'x3); # for testing: all permutations, plus many mor
    +e
    
    ...
    for $i (@x) {
        $i =~ $x and say $i; # was $x =~ $i
    }
    
  2. or download this
    abc
    acb
    ...
    bca
    cab
    cba
    
  3. or download this
    @x = glob('{a,b,c}'x6);
    $x = '(?:a()|a()|b()|b()|c()|c()){6}\1\2\3\4\5\6'; # limited repeats a
    +llowed
    ...
    for $i (@x) {
        $i =~ $x and say $i; # was $x =~ $i
    }
    
  4. or download this
    aaaabc
    aaaacb
    ...
    cccbca
    ccccab
    ccccba
    
  5. or download this
    @x = glob('{abc,bcd,cde}'x3);
    # permutations of 'abc/bcd/cde'
    ...
    for $i (@x) {
        $i =~ $x and say $i; # was $x =~ $i
    }
    
  6. or download this
    abcbcdcde
    abccdebcd
    ...
    bcdcdeabc
    cdeabcbcd
    cdebcdabc
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1226058]
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-25 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found