Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 contemplating the Monastery: (8)
As of 2014-12-26 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls