in reply to more efficient regular expression please
HTH#!/usr/bin/perl use strict; my $str; my $tomatch = 'foobar the vacation.msg is here'; my @permute = map { $str; $str = $_ . $str; } ( reverse( split(//, 'vacation') ) ); $regex = '(\.?(?:' . join('|', reverse(@permute)) . ')\.msg)'; print "$regex\n"; print "Match: $1\n" if ($regex =~ m/$tomatch/ );
|
|---|