Jump to content

PHP regular expression

chat de nuit

Recommended Posts

Hello, I have a very strange problem which I cannot solve.I have a regular expression to check the validity of an input :if (preg_match('/^[a-zA-Z0-9 ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ€().,:\'-]{4,100}$/u',stripslashes($_POST['title']))) This is for a web site in French, and it must accept accentuation. I noticed a very strange problem.If I enter in the input form the word l'hôpital, this works perfectly.If I enter the word l'hopital without the accentuation on the o, and that I use the spellchecker of the web browser to change it to the right spelling, then the regular expression does not work any more. It does not replace any letter bye html_entity, and when I do var_dump on the variable it shows l'hôpital.After doing different test, I noticed that the problem occurs when the accentuated caracter is preceded by an apostrophe.Has anyone of you got any clue on how to proceed to correct this issue, or has come accross a similar problem ?The problem occurs on the live web site, as well as on my development PC.I use PHP 5.3 on apache 2.0Thank you, and sorry for the bad english.. I am French as you may have guessed.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...