Regex to allow for accented characters and apostrophes?


I’m using CodeIgniter to set up a shopping cart. In doing so, I noticed that CI does not allow any products with accented characters to be added to the cart. This is defined in the following regex:

var $product_name_rules = '\\.\\:\\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods

However, I’m having to add products with names such as “Côtes du Rhône”, or “Crème d’Abricot”, which have accents as well as the occasional apostrophe.

Question: how do I modify the above regex to include these characters?


Wanted to add that alternatively, any regex that will allow for html-entities would do the trick as well, for instance with a product name such as “Cuveé du Vigneron” (é = #233 html entity)…

Have you looked into why it doesn’t allow them to be added to the cart? Personally I cannot think of one, other than the URI filtering it applies to routes, but you may find there’s a reason behind it.

Just a thought. :slight_smile:

I hav thought about why they would do that - security reasons I guess. However, if I could just have a regex that allows for html-entities, I’d be good to go, and the regex would still exclude any “dangerous” characters…