regex for filtering non-standard charachters
Posted: Thu Apr 16, 2009 9:00 am
i got this <textarea> that is meant to accept around 350 words, now the audeince of this website will be pasting it from word more than 99% of the time which creates a problem for me becuase of the whole rendering system used by word that converts quotes to “”. but thats only small part of the problem because im filtering them out:
but what about the rest, you got all these symbols in word such as alpha-beta, neq etc... as they just mess up in mysql and even one occasion when i combines symbols and (“”) in the textarea and processed it, the above code was completly ignored and the word engulfed by (“”) was completly denatured. i need some sort of regex to get rid of these unwanted characters, any regex or wisdom is appreciated.. safe
Code: Select all
$data = str_replace("‘", "'", $data);
$data = str_replace("’", "'", $data);
$data = str_replace("“", '"', $data);
$data = str_replace("”", '"', $data);
$data = str_replace("–", "-", $data);