Last active
April 16, 2016 14:44
-
-
Save vsemozhetbyt/39aa3baad20a9f4031fc17bd75f1052b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const gcs = { | |
Lu: 'ABC', | |
Ll: 'абв', | |
Lt: 'ᾼῌῼ', | |
get LC(){return this.Lu + this.Ll + this.Lt}, | |
Lm: 'ʰʱʲ', | |
Lo: 'אבג', | |
get L() {return Object.keys(this).filter(k => /^L[a-z]$/.test(k)) | |
.map(k => this[k]) | |
.join(''); | |
}, | |
Mn: '\u0300\u0301\u0302', | |
Mc: '\u0903\u093B\u093E', | |
Me: '\u0488\u0489\u1ABE', | |
get M() {return Object.keys(this).filter(k => /^M[a-z]$/.test(k)) | |
.map(k => this[k]) | |
.join(''); | |
}, | |
Nd: '123', | |
Nl: 'ᛮᛯᛰ', | |
No: '¼½¾', | |
get N() {return Object.keys(this).filter(k => /^N[a-z]$/.test(k)) | |
.map(k => this[k]) | |
.join(''); | |
}, | |
Pc: '_‿⁀', | |
Pd: '-–—', | |
Ps: '([{', | |
Pe: ')]}', | |
Pi: '«‘“', | |
Pf: '»’”', | |
Po: '!"#', | |
get P() {return Object.keys(this).filter(k => /^P[a-z]$/.test(k)) | |
.map(k => this[k]) | |
.join(''); | |
}, | |
Sm: '+<=', | |
Sc: '$¢£', | |
Sk: '^`¨', | |
So: '¦©®', | |
get S() {return Object.keys(this).filter(k => /^S[a-z]$/.test(k)) | |
.map(k => this[k]) | |
.join(''); | |
}, | |
Zs: '\u00A0\u1680\u2000', | |
Zl: '\u2028', | |
Zp: '\u2029', | |
get Z() {return Object.keys(this).filter(k => /^Z[a-z]$/.test(k)) | |
.map(k => this[k]) | |
.join(''); | |
}, | |
Cc: '\u0000\u0001\u0002', | |
Cf: '\u00AD\u0600\u0601', | |
Cs: '\uD800\uDB7F\uDB80', | |
Co: '\uE000\uF8FF\u{F0000}', | |
Cn: '', | |
get C() {return Object.keys(this).filter(k => /^C[a-z]$/.test(k)) | |
.map(k => this[k]) | |
.join(''); | |
}, | |
}; | |
Object.keys(gcs).forEach(gc => { | |
let result; | |
try { | |
result = gcs[gc].match( new RegExp(`\\p{${gc}}+`, 'ug') ); | |
} catch(e) { | |
result = e.message; | |
} | |
console.log(`${gc}:\t${result}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment