// 基本多言語面(BMP)以外の文字を配列で返す
export const extractUnicode4ByteChars = (v: string) => {
const regex = /[\u{10000}-\u{10FFFF}]/gu // BMP範囲以外
return v.match(regex) || []
}
const text = 'メッせ-z1𩸽✋☀️🥺'
console.log(extractUnicode4ByteChars(text))
// '𩸽🥺'
【JavaScript】文字列から基本多言語面(BMP)以外の文字(UTF-8で4バイトになる文字)を配列で返す
Last updated at Posted at 2024-11-13
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme