Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Exception from a character class

by ambrus (Abbot)
on May 30, 2013 at 20:06 UTC ( #1036126=note: print w/replies, xml ) Need Help??


in reply to Exception from a character class

You're already showing how to use a zero-width assertion, so why not use that to exclude the apsotrophe?

$text =~ s{(?!')\p{Punct}}{}g;
Alternately, how about
{ no warnings "uninitialized"; $text =~ s{(')|\p{Punct}}{$1}g; }

Update: a third solution is to match what you want to keep.

$text = join "", $text =~ m{[\x27\P{punct}]+}g;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1036126]
help
Chatterbox?
[stevieb]: I finally got all of my tests to run against my App::RPi::EnvUI!! I am so pleased :) Now to add more tests, update the documentation, some code cleanup, put in production in my largest operation, and do a non-beta release

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2017-12-16 00:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (446 votes). Check out past polls.

    Notices?