Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Regex question : How to match \w and just the dash

by Stevie-O (Friar)
on Dec 17, 2004 at 21:08 UTC ( #415782=note: print w/ replies, xml ) Need Help??


in reply to Regex question : How to match \w and just the dash

The regex /^\W^-/ will never match anything, because ^ only matches the beginning of a string, and you have a character (\W) before the second ^.

I think that what you want is this:

s/[^\w-]+//g
That will strip out all characters that are neither \w nor a dash.
--Stevie-O
$"=$,,$_=q>|\p4<6 8p<M/_|<('=> .q>.<4-KI<l|2$<6%s!<qn#F<>;$, .=pack'N*',"@{[unpack'C*',$_] }"for split/</;$_=$,,y[A-Z a-z] {}cd;print lc

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2016-07-02 11:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?


















    Results (20 votes). Check out past polls.