Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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


Comment on Re: Regex question : How to match \w and just the dash
Select or Download Code

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 avoiding work at the Monastery: (6)
As of 2014-08-21 05:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (127 votes), past polls