Skip to content

Instantly share code, notes, and snippets.

@godfat
Created May 14, 2011 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save godfat/972085 to your computer and use it in GitHub Desktop.
Save godfat/972085 to your computer and use it in GitHub Desktop.
XRegExp = require('xregexp-all.js')
XRegExp.new = XRegExp.XRegExp
XRegExp.new('\\p{L}+').test('啊囉哈')
# download XRegExp 1.5.0
wget http://xregexp.com/xregexp-min.js
# download XRegExp unicode modules
wget http://xregexp.com/plugins/xregexp-unicode-base.js
wget http://xregexp.com/plugins/xregexp-unicode-categories.js
wget http://xregexp.com/plugins/xregexp-unicode-scripts.js
wget http://xregexp.com/plugins/xregexp-unicode-blocks.js
# cat all files into one. note, xregexp-min.js should be
# on the top. here lexically m is front of u, so we
# don't need bother it
cat xregexp-*.js > xregexp-tmp.js
# convert CRLF to LF
tr -d "\r" < xregexp-tmp.js > xregexp-all.js
# make XRegExp a nodejs module
echo '
XRegExp.new = XRegExp;
var root;
root = (typeof exports !== "undefined" && exports !== null) ? exports : this;
root.XRegExp = XRegExp;' >> xregexp-all.js
@slevithan
Copy link

As of XRegExp v2.0.0, you can just include xregexp-all.js. You can also install it via npm.

@godfat
Copy link
Author

godfat commented May 28, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment