tr/-a-zA-Z0-9//cd;
You could also do
s/[^-a-z0-9]//ig;
If you wanted a regexp solution. However
s/[^-\w]//g;
(which is what I think you think you're looking for) will not do what you want, because \w includes _. | [reply] [d/l] [select] |
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
| [reply] [d/l] [select] |
Think I have a glimmering... but just barely... of what your input might be. Input, please, and if ([A-Za-z\-])+ is not the desired out, a sample of that too? In fact, a tight sample of the script would make it MUCH easier to try to help. | [reply] |
I'll give the offered solutions a go, they make sense. I did not realize that \W included the underscore. Nice to know.
The input will be name and address fields on an order form.
| [reply] |
| [reply] |
Just nit-picking, but keep in mind that \w and \W are not the same thing (note the case / capitalization). In fact, they are each other's complement: a character matched by \w will not be matched by \W, and vice versa.
| [reply] |
To clarify and to be totally A.R., I think you meant "hyphen." HTML provides for both kinds of dashes: 1. –, used for ranges of things (Monday–Friday); 2. —, used for breaks in thought ("Perlmonks—an online community—is a friendly place"), and, of course, the hyphen which is used for word breaks.
All that to say: s/[a-zA-Z\-]+//g; would be my take, not seeing your input.
—Brad "Don't ever take a fence down until you know the reason it was put up." G. K. Chesterton
| [reply] [d/l] [select] |