SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Regex to allow for accented characters and apostrophes?

    Hi,

    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:

    PHP Code:
    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?

    Thanks...

  2. #2
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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)...

  3. #3
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    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.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  4. #4
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AnthonySterling View Post
    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.
    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...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •