in reply to Force ASCII regexp for all perls 5.8+

G'day vsespb,

You could set up something like this just once:

my $d = qr{[0-9]}; my $w = qr{[A-Za-z0-9_]};

And then just use $w and $d instead of \w and \d. That gives you the added benefit of still having \w and \d available if you need them. Here's a minimal test:

$ perl -le ' my $w = qr{[A-Za-z0-9_]}; print q{With \x{424}:}; print 3+6 if "\x{424}" =~ /$w/; print q{With \x{42}:}; print 3+6 if "\x{42}" =~ /$w/; ' With \x{424}: With \x{42}: 9

-- Ken

Replies are listed 'Best First'.
Re^2: Force ASCII regexp for all perls 5.8+
by vsespb (Chaplain) on May 16, 2013 at 07:40 UTC
    Great idea!