[OPEN-ILS-DEV] Enabling Unicode support in regular expressions against patron names (registration form and search patron interface)

Dan Scott denials at gmail.com
Fri May 29 15:07:26 EDT 2009


Hey all:

The regex in the user registration form for names in ue_config.js is:

const nonumRegex	= /^[a-zA-Z]\D*$/; /* no numbers, no beginning whitespace */

Similarly, the regex in the search patron interface (search_form.js) is:

value = value.replace(/^\W+/g,'').replace(/\W+$/g,'');

In the version of JavaScript used by xulrunner-1.9, \W is interpreted
as meaning "anything other than ASCII word characters".

These regexes pose a problem for our internationalization goals, as by
default it prevents people with names like Étienne or ԱԲԳԱՐ from being
registered or searched. That's not cool.

The regexes should also be harmonized so that we're checking for the
same thing in each interface.

So, how about:

const nonumRegex	= /^[^\d\s]+[\d]*$/; /* no numbers, no beginning whitespace */

and:

value = value.replace(/^[\d\s]+/g,'').replace(/[\d\s]+$/g,'');

I think this achieves the same goals (at least, as described in the
comments in ue_config.js) in a Unicode-friendly way. I have tested the
regexes and they work.

-- 
Dan Scott
Laurentian University


More information about the Open-ils-dev mailing list