Skip to content

Commit

Permalink
update property-escapes docs (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Sep 23, 2023
1 parent c2236ab commit 947f2cd
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions property-escapes.md
@@ -1,28 +1,26 @@
# Unicode property escapes in _regexpu_

To opt-in to experimental support for [Unicode property escapes](https://github.com/mathiasbynens/es-regexp-unicode-property-escapes), enable [the `unicodePropertyEscape` option](README.md#unicodepropertyescape-default-false).
To enable support for [Unicode property escapes](https://github.com/mathiasbynens/es-regexp-unicode-property-escapes), set [the `unicodePropertyEscape` option](README.md#stable-regular-expression-features) to `transform`.

```js
rewritePattern('\\p{Script_Extensions=Anatolian_Hieroglyphs}', 'u', {
'unicodePropertyEscape': true
'unicodePropertyEscapes': 'transform'
});
// → '(?:\\uD811[\\uDC00-\\uDE46])'
// → '[\\u{14400}-\\u{14646}]'
```

If you’re targeting ES2015 environments exclusively, consider enabling [the `useUnicodeFlag` option](README.md#useunicodeflag-default-false) for simpler (but not necessarily more compact) output.
If you’re targeting ES5 environments, consider enabling [the `unicodeFlag` option](README.md#stable-regular-expression-features).

```js
rewritePattern('\\p{Script_Extensions=Anatolian_Hieroglyphs}', 'u', {
'unicodePropertyEscape': true,
'useUnicodeFlag': true
'unicodePropertyEscape': 'transform',
'unicodeFlag': 'transform'
});
// → '[\\u{14400}-\\u{14646}]'
// → '(?:\\uD811[\\uDC00-\\uDE46])'
```

[An online demo is available.](https://mothereff.in/regexpu#input=var+regex+%3D+/%5Cp%7BScript_Extensions%3DGreek%7D/u%3B&unicodePropertyEscape=1)

Note that this feature is non-standard. This implementation may or may not reflect what eventually gets specified.

What follows is an exhaustive overview of the Unicode properties and values that _regexpu_ supports in `\p{…}` and `\P{…}` expressions in regular expressions with the `u` flag.

## Non-binary properties
Expand Down

0 comments on commit 947f2cd

Please sign in to comment.