0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【JavaScript】文字列から基本多言語面(BMP)以外の文字(UTF-8で4バイトになる文字)を配列で返す

Last updated at Posted at 2024-11-13
// 基本多言語面(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))
// '𩸽🥺'
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?