![]() |
RegEx
Hi all,
My other post seemed to be a little much?! Maybe this one will be easier... I am trying to strip an input of any special characters using regExpressions, but am not quite understaning how to get rid of anything but letters and numbers. Isn't there a replace /(!@#%$*())/ all that with "" expression? Here is what I have so far: Code:
function updatelink()Thanks! |
This regex could help
Code:
[^A-Za-z0-9]+or also the W that matches all alphanumeric, but the W treats the underscore like an alphanumeric. so this Code:
(/W)+Code:
[^A-Za-z0-9_]+ |
Quote:
JavaScript Code:
|
Hey Ya! Thanks you guys.
In a string link this: Code:
var clean = title.replace(/\s+/g, "-");Like so: Code:
var clean = title.replace(/(/W)+/g, "-");Confusing stuff, but essential! |
my bad, it is \W
so something like this would do javascript Code:
it is better to use innerHTML than value, I think that is only for form elements, I am not sure. |
Great. I was thinking that \W need the escape. Thanks for the post!
|
no problem
|
| All times are GMT. The time now is 10:30 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0