Regex: How to leave out webding font characters?

Posted by DS on Stack Overflow See other posts from Stack Overflow or by DS
Published on 2010-05-05T20:50:51Z Indexed on 2010/05/05 23:08 UTC
Read the original article Hit count: 149

Filed under:

Hi,

I've a free text field on my form where the users can type in anything. Some users are pasting text into this field from Word documents with some weird characters that I don't want to go in my DB. (e.g. webding font characters) I'm trying to get a regular expression that would give me only the alphanum and the punctuation characters. But when I try the following, the output is still all the characters. How can I leave them out?

<html><body><script type="text/javascript">var str="???????";document.write(str.replace(/[^a-zA-Z 0-9 [:punct]]+/g, " "));</script></body></html>

© Stack Overflow or respective owner

Related posts about regex