keepup-ECMAScript
  • About
  • Proposal
    • using
    • Temporal
  • ES2025
    • Promise.try
    • Sync Iterator helpers
    • Import Attributes
    • JSON Modules
    • New Set Methods
    • RegExp Modifiers
    • Duplicate named capture groups
  • ES2024
    • Resizable and growable ArrayBuffers
    • RegExp v flag with set notation + properties of strings
    • Atomics.waitAsync
    • Well-Formed Unicode Strings
    • array grouping
    • Promise withResolvers
  • ES2023
    • Symbols as WeakMap key
    • Hashbang Grammar
    • Array.findLast, findLastIndex
    • 配列の非破壊操作
  • ES2022
    • Private class fields
    • Regexp match indices
    • Top-level await
    • Private fields in-in
    • Array.at
    • Object.hasOwn
    • Class static block
    • Error cause
GitBook提供
このページ内
GitHubで編集
  1. ES2024

RegExp v flag with set notation + properties of strings

前へResizable and growable ArrayBuffers次へAtomics.waitAsync

最終更新 1 年前

CtrlK

正規表現でUnicode Character Propertiesが使えるようになった(~ES2018)。 \pに続けてシンボルを指定する。

const re = /^\p{Emoji}$/u;

re.test("⚽"); // true

複数コードポイントからなる絵文字はチェックできなかった。

re.test('👨🏾‍⚕️');

新しいシンボル追加により、複数コードポイントが指定できるようになった。

const re = /^\p{RGI_Emoji}$/v;

re.test('👨🏾‍⚕️');
// true

Hight Level API

正規表現の部分集合や差分が指定できるようになった。 この指定はvフラグを付けて使用する。

// 絵文字からASCIIを除く
[\p{Emoji}--\p{ASCII}]

/[\p{Emoji}--\p{ASCII}]/v.test("");

https://zenn.dev/pixiv/articles/54e5d29c54e7f5 が詳しい。