How we can delete some special character from a string by javascript
The best way is to replace it, either using a string or regular expression.
String:
// JavaScript Document
var string = 'Hello world!';
alert( string.replace( 'world', '' ) ); // Alerts "Hello !"
Regular Expression:
// JavaScript Document
var string = 'Hello world!';
alert( string.replace( /o/, '' ) ); // Alerts "Hell wrld!"
Remove special characters (like !, >, ?, ., # etc.,) from a string ...
Remove special characters from a string using JavaScript
http://digg.com/programming/Remove_special_characters_from_a_string_using_JavaScript
Well,
if the string to get cleaned up is mystring;
mysring = mystring.replace(/[^a-zA-Z 0-9]+/g,'');
will remove all charectes other than alpahnumeric from your string. You can modify the regular expression accordingly if you wan tot exclude some special characters from cleaning up.
Well,
if the string to get cleaned up is mystring;
mysring = mystring.replace(/[^a-zA-Z 0-9]+/g,'');
will remove all charectes other than alpahnumeric from your string. You can modify the regular expression accordingly if you wan tot exclude some special characters from cleaning up.