Remove unwanted Characters using Javascript (JS)

Remove unwanted characters using JS

Using below JS (Javascript), you can remove the unwanted characters on your content

(a) Code to Remove Non-numerical characters


(b) Code to Remove Non-alphabetic characters


(c) Code to Remove non-alphanumeric characters


(d) Code to Remove white_space only


Notes: syntax => element.replace(expression,replace_content);
1.Some Expressions are,
“/[0-9]/g” or “/ \d/ g” => Select digits only
“/[^0-9]/g” or “/ \D /g” => Select all non-digits
“/[a-zA-Z]/g” => Select Alphabetics only
“/[^a-zA-Z]/g” or “/ \D /g” => Select all non-alphabetics
“/[a-zA-Z0-9]/g” or “/ \D /g” => Select all Alpha-numeric characters
“/[^a-zA-Z0-9]/g” or “/ \D /g” => Select all Non-alphanumeric characters
2.Replace_Content => you can add any variable type as a replace content include white-space(” “) and empty field(“”).

Leave a Reply

%d bloggers like this: