I need to filter out strings that contain anything other than letters, numbers, dots, hyphens, apostrophes or spaces.
Strings with letters, numbers, dots, hyphens and spaces pass the test, but when they contain an apostrophe it fails. (The escape characters on the dot and hyphen don't seem to be making any difference so I put them in just to be sure)
Any thoughts on this?
if (preg_match("/[^a-zA-Z0-9\.\-\'\\s]/", $some_var)){
echo "Invalid characters";
}