Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Exception from a character class

by AnomalousMonk (Chancellor)
on May 30, 2013 at 19:06 UTC ( #1036123=note: print w/replies, xml ) Need Help??

in reply to Exception from a character class

I think the set manipulation operations used in the approach of Re: Exception from a character class were only introduced with Perl version 5.16.

The following approach uses only 'old-style' character classes. It depends on a kind of double-negation to match all characters that are not non-digits and also not specific digits. (\P{Whatever} is the inverse class of  \p{Whatever} – note P versus p.) Of course, adapt this to your punctuation application.

>perl -wMstrict -le "my $s = 'abc 123 def 45678 g 90 h'; print qq{'$s'}; ;; $s =~ s{ [^\P{PosixDigit}257] }{-}xmsg; print qq{'$s'}; " 'abc 123 def 45678 g 90 h' 'abc -2- def -5-7- g -- h'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1036123]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2018-05-22 21:59 GMT
Find Nodes?
    Voting Booth?