zotero/zotero — pull request #213 by aurimasv (2012-12-19 12:59:56+00:00)
Title: Add XRegExp to Zotero.Utilities

Essentially this adds Unicode support for regular expressions.

For more info on XRegExp see the code and README [here](https://github.com/slevithan/xregexp) and some more documentation [here](http://xregexp.com/)

This is fairly actively maintained by an expert in the field of regular expressions. I merged in the most recent commit (13 days old) from the master branch, which appears to be a pre-release version. This may or may not be a good idea...

Code is licensed under the [MIT License](http://mit-license.org/), so it should not be a problem, but I'm no expert. I think I need to include the license somewhere. And that also reminds me that Steven Levithan would also need a mention in the About dialog.

We only need the files from the `src` subfolder. I tried to figure out how to do this properly using git, but I didn't find a good solution. `submodules` would include the entire repo. From what I read, subtree merge might work, but I'm on Windows and it's not available on cygwin yet (nor TortoiseGit from what I can tell). Do let me know if there's a better way to handle this.

To me it seems that the right place for this function is in Zotero.Utilities. I also wanted to make this available in translators. `Zotero.Utilities.Translate` copies `Zotero.Utilities` as it's prototype. I tried adding XRegExp to the `Zotero.Utilities.Translate.prototype` after the fact, but it did not help expose it to translators. I'm not sure what I am overlooking. But this is why XRegExp is, a bit inelegantly, loaded before Zotero.Utilities and then added to the object in utilities.js. Is there a better way to import it into Zotero.Utilities?

The main motivation for this is being able to access the multilingual Uppercase and Lowercase character classes in regex's, which should help us improve title-casing, cleaning up and punctuating author initials, and various other places where we could do a better job handling multilingual content. It also has a neat `matchRecursive` function, which could prove useful (see documentation).