>I'm trying to get an apostrophe (and a dash, as well) to be
>included in a preg_match expression, but I don't know how to escape the
>characters.
Advertising
The dash has to come "last" in your [] grouping:
[!a-zA-Z-]
^
|
This will work.
The ' is a matter of counting how many \s PHP wants and how many Perl wants.
Inside "", PHP doesn't need ' escaped at all.
Perl needs a \, but in PHP, you need \\ to get a \ inside the quotes.
So I'm betting it's more like:
"^[!a-zA-Z\\'-]$"
NOTE:
I'm not sure what you think ^ at the end of the [] means, but I don't think
it's what you want...
I dunno what you were trying to do with the / in there...
If you just want / as a character, I know PHP doesn't need any escaping, but
God only knows about the Perl part of it.
>
><?php
>if (preg_match("^[!a-zA-Z-/\\\'/]^", $_POST['ssname'])) die
>("<h5>Numbers and special characters not allowed in 'Surname'<br><br>
> Click 'Back' on your browser to re-enter
>information.</h5>");
>
>?>
>Any help will be greatly appreciated.
>
>Tia,
>Andre
--
Like Music? http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php