Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2017-11-25 04:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (355 votes). Check out past polls.

    Notices?