Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Exception from a character class

by AnomalousMonk (Abbot)
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'


Comment on Re: Exception from a character class
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1036123]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (19)
As of 2015-07-02 17:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (44 votes), past polls