Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

regex and internationalisation

  • 29-06-2012 8:33pm
    #1
    Registered Users, Registered Users 2 Posts: 859 ✭✭✭


    I'm validating user input on the browser to exclude special chars like !"£$%^&* using a regex something like [a-zA-Z0-9 ]

    The regex is doing what I want, my question is about internationalisation, (which is being done later, (I know))

    Will I have to adjust my regex per locale and hence should it itself be an externalisable string so that it is easier to do?

    Tks,
    Owen.


Comments

  • Registered Users, Registered Users 2 Posts: 2,040 ✭✭✭Colonel Panic


    Best to plan ahead and have it possible to localise! Especially if it's being done later.


  • Registered Users, Registered Users 2 Posts: 1,127 ✭✭✭smcelhinney


    In this instance what I would do is externalise in a properties file or locale bundle (Java speak).

    Eg.

    regex_en.properties might contain
    valid_string_regex=/[A-Za-z0-9 ]+/

    and regex_fr.properties might contain
    valid_string_regex=/[A-Za-z0-9éáí ]+/ (..etc)

    HTH
    Stephen


  • Registered Users, Registered Users 2 Posts: 1,110 ✭✭✭Skrynesaver


    Many languages' regex library is based on Perl's (PCRE - Perl compatible regular expressions). Perl has locale dependent character class defined what you seem to want is \w (a word character). As it locale dependent i18n is automatic.

    Check the docs for your languages regex implementation.


Advertisement