JSFiddle - React, Tailwind, and code Playground
by pimvdb
HTML
<script src="http://xregexp.com/xregexp.js"></script>
<script src="http://xregexp.com/plugins/xregexp-unicode-base.js"></script>
<script src="http://xregexp.com/plugins/xregexp-unicode-categories.js"></script>
JavaScript
var types = [
'Ll', 'Lu', 'Lt', 'Lm', 'Lo', 'Mn', 'Mc', 'Me', 'Nd', 'Nl',
'No', 'Pd', 'Ps', 'Pe', 'Pi', 'Pf', 'Pc', 'Po', 'Sm', 'Sc',
'Sk', 'So', 'Zs', 'Zl', 'Zp', 'Cc', 'Cf', 'Co', 'Cs', 'Cn'
];
function getType(char) {
var char = (char + "").charAt(0);
for(var i = 0; i < types.length; i++) {
if(XRegExp("\\p{" + types[i] + "}").test(char)) {
return types[i];
}
}
}
alert(getType(" "));