I'm having a little problem with apostrophes in a reular expression.
Here is my current (working) code:
CODE
$comments = $_POST['comments'];
if (preg_match('/[^a-zA-Z0-9_ ,!\(\)\?\.-]/', $comments)) {
$file = "failstring.html";
}
$file = "guestbook.html";
if (preg_match('/[^a-zA-Z0-9_ ,!\(\)\?\.-]/', $comments)) {
$file = "failstring.html";
}
$file = "guestbook.html";
Obviously failstring.html is my error message, and guestbook.html is my ok message.
This code currently checks for anyting other than a-Z, 0-9, _ , ! ( ) ? . - and fails if it finds anything.
I want to include apostrophes in this list, but keep getting an error message at the preg_match line. Basically, I think the apostrophe in the regular expression makes it think the string has ended. I have tried escaping the character.
Any ideas?
Thanks, swordz
