I'm looking for a regular expression that can remove all the following characters from a string (and Whitespace too):
~ % & \ ; : " ' , < > ? #
Can you help me? I'm coding in ActionScript 3.
var nospecial=/^[^* | \ " : < > [ ] { } ` \ ( ) '' ; @ & $]+$/; if(address. match(nospecial)){ alert('Special characters like * | \ " : < > [ ] { } ` \ ( ) \'\' ; @ & $ are not allowed'); return false; but it is not working.
Answer : Use [^[:alnum:]] to remove ~! @#$%^&*(){}_+:"<>?,./;'[]-= and use [^a-zA-Z0-9] to remove also â í ü Â á ą ę ś ć in regex or regexpr functions.
In ActionScript it goes like
yourString.replace(/[~%&\\;:"',<>?#\s]/g,"");
Same in Perl:
$_ = "~ % & \\ ; : \" ' , < > ? #";
s/[~%&\\;:"',<>?#\s]//g;
print; #prints nothing
[~%&\\;:"',<>?#\s]+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With