HTTP/2 200
content-type: text/html
x-guploader-uploadid: AAwnv3J_Ny1dmRgUSlf_0MCnKOWtuubGQt5C_jG-Un-fEpwv11KUTKuBJJJ9FwRZKyGx1ji1
cache-control: public, max-age=3600
expires: Thu, 09 Oct 2025 14:42:55 GMT
last-modified: Thu, 09 Oct 2025 01:14:30 GMT
etag: W/"42aa7b935214a1fbc14f242b260a5cb0"
x-goog-generation: 1759972469974398
x-goog-metageneration: 1
x-goog-stored-content-encoding: identity
x-goog-stored-content-length: 168686
x-goog-meta-goog-reserved-file-mtime: 1759970707
x-goog-hash: crc32c=L7ymJA==, md5=Qqp7k1IUofvBTyQrJgpcsA==
x-goog-storage-class: STANDARD
accept-ranges: none
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
alt-svc: clear
referrer-policy: strict-origin-when-cross-origin
x-content-type-options: nosniff
strict-transport-security: max-age=63072000
content-security-policy: default-src 'self'; script-src 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://www.googletagmanager.com/gtag/js assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; script-src-elem 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://www.googletagmanager.com/gtag/js assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; style-src 'report-sample' 'self' 'unsafe-inline'; object-src 'none'; base-uri 'self'; connect-src 'self' developer.allizom.org bcd.developer.allizom.org bcd.developer.mozilla.org updates.developer.allizom.org updates.developer.mozilla.org https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com https://incoming.telemetry.mozilla.org https://observatory-api.mdn.allizom.net https://observatory-api.mdn.mozilla.net https://api.github.com/search/issues stats.g.doubleclick.net https://api.stripe.com; font-src 'self'; frame-src 'self' interactive-examples.mdn.mozilla.net interactive-examples.mdn.allizom.net mdn.github.io live-samples.mdn.mozilla.net live-samples.mdn.allizom.net *.mdnplay.dev *.mdnyalp.dev *.play.test.mdn.allizom.net https://v2.scrimba.com https://scrimba.com jsfiddle.net www.youtube-nocookie.com codepen.io survey.alchemer.com https://js.stripe.com; img-src 'self' data: *.githubusercontent.com *.googleusercontent.com *.gravatar.com mozillausercontent.com firefoxusercontent.com profile.stage.mozaws.net profile.accounts.firefox.com developer.mozilla.org mdn.dev interactive-examples.mdn.mozilla.net interactive-examples.mdn.allizom.net wikipedia.org upload.wikimedia.org https://mdn.github.io/shared-assets/ https://mdn.dev/ https://*.google-analytics.com https://*.googletagmanager.com www.gstatic.com; manifest-src 'self'; media-src 'self' archive.org videos.cdn.mozilla.net https://mdn.github.io/shared-assets/; child-src 'self'; worker-src 'self';
x-frame-options: DENY
origin-trial: AxVILwizhbMjxFeHOn1P3R8niO1RJY/smaK4B4d1rLzc1gTaxtXMSaTi+FoigYgCw40uFRDwFcEAeqDR+vVLOW4AAABfeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb25WMiIsImV4cGlyeSI6MTc0MjA3OTYwMH0=
x-cloud-trace-context: cb28daf6d63440f4392c0520414d791c
date: Thu, 09 Oct 2025 13:42:56 GMT
server: Google Frontend
via: 1.1 google
vary: Accept-Encoding
content-encoding: gzip
x-cache: miss
RegExp.prototype.unicode - JavaScript | MDN
const regex1 = new RegExp("\u{61}");
const regex2 = new RegExp("\u{61}", "u");
console.log(regex1.unicode);
// Expected output: false
console.log(regex2.unicode);
// Expected output: true
console.log(regex1.source);
// Expected output: "a"
console.log(regex2.source);
// Expected output: "a"
RegExp.prototype.unicode
の値は true
ならば u
フラグが使用されていることを示し、そうでなければ false
となります。u
フラグは Unicode に関連する様々な機能を有効にします。 "u" フラグを使用すると、次のようになります。
- Unicode コードポイントエスケープ ( \u{xxxx}, \p{UnicodePropertyValue}) は、ID エスケープの代わりにそのように解釈されます。例えば、
/\u{61}/u
は "a"
に一致しますが、/\u{61}/
(u
フラグなし)は "u".repeat(61)
に一致します。 \u
が u
1 文字と同等になるからです。
- サロゲートペアは 2 つの別々の文字ではなく、全体の文字として解釈されます。例えば
/[😄]/u
は"😄"
にのみ一致し、"\ud83d"
には一致しません。
lastIndex
が自動的に進む場合(exec()
を呼び出した場合など)、Unicode 正規表現は UTF-16 コード単位ではなく Unicode コードポイント単位で進みます。
構文の間違いを防ぐために、構文解析の動作を変更したものが他にもあります(正規表現構文の厳格モードに似ています)。これらの構文はすべて非推奨であり、ウェブの互換性のためだけに残されているもの
ですので、頼らないでください。
unicode
の設定アクセサーは undefined
です。このプロパティを直接変更することはできません。
Unicode 対応モードと言う言葉を使うときは、u
または v
のどちらかのフラグがついた正規表現を指し、この場合は正規表現が Unicode に関連した機能(Unicode 文字クラスエスケープなど)が利用できるようになり、もっと厳格化した構文ルールになります。u
と v
は同じ正規表現を互換性のない方法で解釈するため、両方のフラグを使用すると SyntaxError
になります。
同様に、正規表現が u
フラグも v
フラグも持たない場合、Unicode 非対応モードとなります。この場合、正規表現は UTF-16 コード単位の並びとして解釈され、たくさんの古い構文が構文エラーにならなくなります。
const regex = /\u{61}/u;
console.log(regex.unicode); // true