For some reason, people cannot write apostrophes without resulting with an error... For example: Prud'homme will not work

Here's my line of code:

$string_exp = "/^[A-Za-zé.¸UûÙùàÀèÈéÉïÏîÎôÔêÊçÇ .,\'-]+$/";

I don't understand why it doesn't work, does someone know?

7 Years
Discussion Span
Last Post by minitauros

I don't know everything about regexps, but a dot should be escaped, or it will be treated as "any character". A dot matches any charachter if it is not escaped properly.

Same goes for the comma and dash, backslash and ', in other words, all characters that have a function within a regexp. They should all be escaped properly. [A-Z] means A to Z, while [A\-Z] means A, - and Z.

Edited by minitauros: n/a


So how should I change my code in order for this to work? I'm kind of a google learner so I don't fully understand it yet

Thank you for helping buddy I really need it!

Edited by riseguim: n/a


$string_exp = "/^[A-Za-zé\.¸UûÙùàÀèÈéÉïÏîÎôÔêÊçÇ \,\\\'\-]+$/";

Although I'm not sure if all those special characters will work. Never tried it, so I'm not certain.


IT WORKS !!! Thank you so much for you help, you just made my entire day!

Thanks again buddy!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.