My application was relying on this function to test if a string is Korean or not :
const isKoreanWord = (input) => {
const match = input.match(/[u3131-uD79D]/g);
return match ? match.length === input.length : false;
}
isKoreanWord('??'); // true
isKoreanWord('mandu'); // false
until I started to include Chinese support and now this function is incoherent :
isKoreanWord('幹嘛'); // true
I believe this is caused by the fact that Korean characters and Chinese ones are intermingled into the same Unicode range.
How should I correct this function to make it returns true
if the input contains only Korean characters ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…