Help for this page

Select Code to Download


  1. or download this
    my @values = qw/ a ab. d ef def g|h /;
    my ($regex) = map { qr/$_/ }          # 5.
    ...
        sort { length $b <=> length $a }  # 2.
        @values;                          # 1.
    print "$regex\n";                     # 6.
    
  2. or download this
    (?^:ab\.|def|g\|h|ef|a|d)
    
  3. or download this
    if ($input=~$regex) {
        print "It matches!\n";
    ...
    while ($input=~/($regex)/g) {
        print "Found string: $1\n";
    }
    
  4. or download this
    my %map = ( a=>1, ab=>23, cd=>45 );   # 1.
    my ($regex) = map { qr/$_/ }          # 2.
    ...
        s/($regex)/$map{$1}/g;            # 6.
        print "$before -> $_\n";          # 7.
    }
    
  5. or download this
    abcd -> 2345
    aacd -> 1145
    abaab -> 23123