- 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.
- or download this
(?^:ab\.|def|g\|h|ef|a|d)
- or download this
if ($input=~$regex) {
print "It matches!\n";
...
while ($input=~/($regex)/g) {
print "Found string: $1\n";
}
- 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.
}
- or download this
abcd -> 2345
aacd -> 1145
abaab -> 23123