in reply to Re: Idiom for a regex translation
in thread Idiom for a regex translation

I tried to run this, but it didn't do anything (the string was unmodified). A quick read later, and I came up with this...
use Regexp::Common 'pattern'; pattern name => ['squish'], create => '.', subs => sub { $_[1] =~ s/\W+//g; }; my $name = "Rob J Anderson"; my $squished_name = $RE{squish}->subs($name); print "name :$name\n"; print "squished name :$squished_name\n"; __OUTPUT__ name :Rob J Anderson squished name :RobJAnderson
Which fulfils all my requirements. I'm not sure about the 'create' parameter though. It seemed mandatory, but I can't see that it gets used in this context.

Anyway, thanks for all the responses.