diff --git a/files/en-us/web/javascript/reference/deprecated_and_obsolete_features/index.md b/files/en-us/web/javascript/reference/deprecated_and_obsolete_features/index.md index 76c78b3a0cf3759..8bf16bdc9b81786 100644 --- a/files/en-us/web/javascript/reference/deprecated_and_obsolete_features/index.md +++ b/files/en-us/web/javascript/reference/deprecated_and_obsolete_features/index.md @@ -67,7 +67,7 @@ The following regex syntaxes are deprecated and only available in non-[unicode]( - [Lookahead assertions](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookahead_assertion) are [quantifiable](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Quantifier). - [Backreferences](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Backreference) that do not refer to an existing capturing group become [legacy octal escapes](#escape_sequences). - In [character classes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class), character ranges where one boundary is a character class makes the `-` become a literal character. -- [Escape sequences](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Escape_character) that're not one of the recognized kinds become "identity escapes". +- An escape sequence that's not one of the recognized kinds becomes an ["identity escape"](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Escape_character). - Escape sequences within [character classes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class) of the form `\cX` where `X` is a number or `_` are decoded in the same way as those with ASCII letters: `\c0` is the same as `\cP` when taken modulo 32. In addition, if the form `\cX` is encountered anywhere where `X` is not one of the recognized characters, then the backslash is treated as a literal character. - The sequence `\k` within a regex that doesn't have any [named capturing groups](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Named_capturing_group) is treated as an identity escape. - The syntax characters `]`, `{`, and `}` may appear literally without escaping if they cannot be interpreted as the end of a character class or quantifier delimiters. diff --git a/files/en-us/web/javascript/reference/regular_expressions/backreference/index.md b/files/en-us/web/javascript/reference/regular_expressions/backreference/index.md index 41494db192eb98a..285f00af65218c2 100644 --- a/files/en-us/web/javascript/reference/regular_expressions/backreference/index.md +++ b/files/en-us/web/javascript/reference/regular_expressions/backreference/index.md @@ -21,7 +21,7 @@ A **backreference** refers to the submatch of a previous [capturing group](/en-U ## Description -A backreference is a way to match the same text as previously matched by a capturing group. Capturing groups count from 1, so the first capturing group's result can be referenced with `\1`, the second with `\2`, and so on. `\0` is an [escape character](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Escape_character) for the NUL character. +A backreference is a way to match the same text as previously matched by a capturing group. Capturing groups count from 1, so the first capturing group's result can be referenced with `\1`, the second with `\2`, and so on. `\0` is a [character escape](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape) for the NUL character. In [case-insensitive](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase) matching, the backreference may match text with different casing from the original text. diff --git a/files/en-us/web/javascript/reference/regular_expressions/character_class/index.md b/files/en-us/web/javascript/reference/regular_expressions/character_class/index.md index 94e44f34152bbc0..81d084baa9f7402 100644 --- a/files/en-us/web/javascript/reference/regular_expressions/character_class/index.md +++ b/files/en-us/web/javascript/reference/regular_expressions/character_class/index.md @@ -25,7 +25,7 @@ A character class specifies a list of characters between square bracket and matc - A single character: matches the character itself. - A range of characters: matches any character in the inclusive range. The range is specified by two characters separated by a dash (`-`). The first character must be smaller in character value than the second character. -- Escape sequences: `\b`, `\-`, [character class escapes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class_escape), [Unicode character class escapes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape), and other [escape characters](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Escape_character). +- Escape sequences: `\b`, `\-`, [character class escapes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class_escape), [Unicode character class escapes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape), and other [character escapes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape). These syntaxes can occur any number of times, and the character sets they represent are unioned. For example, `/[a-zA-Z0-9]/` matches any letter or digit. @@ -68,5 +68,5 @@ The `^` prefix in a character class inverts the match. For example, `[^abc]` mat - [Regex reference](/en-US/docs/Web/JavaScript/Reference/Regular_expressions) - [Character class escape: `\d`, `\D`, `\w`, `\W`, `\s`, `\S`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class_escape) - [Unicode character class escape: `\p{...}`, `\P{...}`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape) -- [Escape character: `\n`, `\u{...}`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Escape_character) +- [Character escape: `\n`, `\u{...}`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape) - [Disjunction: `|`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Disjunction) diff --git a/files/en-us/web/javascript/reference/regular_expressions/character_class_escape/index.md b/files/en-us/web/javascript/reference/regular_expressions/character_class_escape/index.md index 1f997654fd89e79..423c7bf16749812 100644 --- a/files/en-us/web/javascript/reference/regular_expressions/character_class_escape/index.md +++ b/files/en-us/web/javascript/reference/regular_expressions/character_class_escape/index.md @@ -17,7 +17,7 @@ A **character class escape** is an escape sequence that represents a set of char ## Description -Unlike [escape characters](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Escape_character), character class escapes represent a predefined _set_ of characters, much like a [character class](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class). The following character classes are supported: +Unlike [character escapes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape), character class escapes represent a predefined _set_ of characters, much like a [character class](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class). The following character classes are supported: - `\d` - : Matches any digit character. Equivalent to `[0-9]`. @@ -28,7 +28,7 @@ Unlike [escape characters](/en-US/docs/Web/JavaScript/Reference/Regular_expressi The uppercase forms `\D`, `\W`, and `\S` negates the match or `\d`, `\w`, and `\s`, respectively. They match any character that is not in the set of characters matched by the lowercase form. -[Unicode character class escapes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape) start with `\p` and `\P`, but they are only supported in [unicode mode](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode). In non-unicode mode, they are [identity escapes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Escape_character) for the `p` or `P` character. +[Unicode character class escapes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape) start with `\p` and `\P`, but they are only supported in [unicode mode](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode). In non-unicode mode, they are [identity escapes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape) for the `p` or `P` character. Character class escapes can be used in [character classes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class). However, using them as boundaries of character ranges is a [deprecated syntax for web compatibility](/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features#regexp) and you should not rely on it. @@ -38,5 +38,5 @@ Character class escapes can be used in [character classes](/en-US/docs/Web/JavaS - [Regex reference](/en-US/docs/Web/JavaScript/Reference/Regular_expressions) - [Character class: `[...]`, `[^...]`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class) - [Unicode character class escape: `\p{...}`, `\P{...}`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape) -- [Escape character: `\n`, `\u{...}`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Escape_character) +- [Character escape: `\n`, `\u{...}`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape) - [Disjunction: `|`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Disjunction) diff --git a/files/en-us/web/javascript/reference/regular_expressions/escape_character/index.md b/files/en-us/web/javascript/reference/regular_expressions/escape_character/index.md index 716604eaf1c5f60..731cbd9cbf4baa0 100644 --- a/files/en-us/web/javascript/reference/regular_expressions/escape_character/index.md +++ b/files/en-us/web/javascript/reference/regular_expressions/escape_character/index.md @@ -1,11 +1,11 @@ --- -title: "Escape character: \\n, \\u{...}" -slug: Web/JavaScript/Reference/Regular_expressions/Escape_character +title: "Character escape: \\n, \\u{...}" +slug: Web/JavaScript/Reference/Regular_expressions/Character_escape --- {{JsSidebar}} -An **escape character** represents a character that may not be able to be conveniently represented in its literal form. +A **character escape** represents a character that may not be able to be conveniently represented in its literal form. ## Syntax diff --git a/files/en-us/web/javascript/reference/regular_expressions/index.md b/files/en-us/web/javascript/reference/regular_expressions/index.md index 8aca7ebd859e47b..423401e0a1ead6f 100644 --- a/files/en-us/web/javascript/reference/regular_expressions/index.md +++ b/files/en-us/web/javascript/reference/regular_expressions/index.md @@ -44,7 +44,7 @@ A **regular expression** (_regex_ for short) enable - : Matches any character in or not in a predefined set of characters. - [Unicode character class escape: `\p{...}`, `\P{...}`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape) - : Matches any character in or not in a set of Unicode characters identified by a Unicode property. -- [Escape character: `\n`, `\u{...}`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Escape_character) +- [Character escape: `\n`, `\u{...}`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape) - : Matches a character that may not be able to be conveniently represented in its literal form. ### Other features diff --git a/files/en-us/web/javascript/reference/regular_expressions/named_backreference/index.md b/files/en-us/web/javascript/reference/regular_expressions/named_backreference/index.md index 5175d7aabde9cd4..55a55f56a8203b1 100644 --- a/files/en-us/web/javascript/reference/regular_expressions/named_backreference/index.md +++ b/files/en-us/web/javascript/reference/regular_expressions/named_backreference/index.md @@ -22,7 +22,7 @@ A **named backreference** refers to the submatch of a previous [named capturing Named backreferences are very similar to normal backreferences: it refers to the text matched by a capturing group and matches the same text. The difference is that you refer to the capturing group by name instead of by number. This makes the regular expression more readable and easier to refactor and maintain. -In non-[unicode](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode) mode, the sequence `\k` only starts a named backreference if the regex contains at least one named capturing group. Otherwise, it is an [identity escape](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Escape_character) and is the same as the literal character `k`. This is a [deprecated syntax for web compatibility](/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features#regexp) and you should not rely on it. +In non-[unicode](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode) mode, the sequence `\k` only starts a named backreference if the regex contains at least one named capturing group. Otherwise, it is an [identity escape](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape) and is the same as the literal character `k`. This is a [deprecated syntax for web compatibility](/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features#regexp) and you should not rely on it. ```js /\k/.test("k"); // true diff --git a/files/en-us/web/javascript/reference/regular_expressions/quantifier/index.md b/files/en-us/web/javascript/reference/regular_expressions/quantifier/index.md index 29e05d1305f65ec..65662cf516702f6 100644 --- a/files/en-us/web/javascript/reference/regular_expressions/quantifier/index.md +++ b/files/en-us/web/javascript/reference/regular_expressions/quantifier/index.md @@ -61,7 +61,7 @@ re.test("aa"); // false re.test("a{1, 3}"); // true ``` -This behavior is fixed in the [`u`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode) mode, where braces cannot appear literally without [escaping](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Escape_character). The ability to use `{` and `}` literally without escaping is a [deprecated syntax for web compatibility](/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features#regexp) and you should not rely on it. +This behavior is fixed in the [`u`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode) mode, where braces cannot appear literally without [escaping](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape). The ability to use `{` and `}` literally without escaping is a [deprecated syntax for web compatibility](/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features#regexp) and you should not rely on it. ```js /a{1, 3}/u; // SyntaxError: Invalid regular expression: Incomplete quantifier diff --git a/files/en-us/web/javascript/reference/regular_expressions/unicode_character_class_escape/index.md b/files/en-us/web/javascript/reference/regular_expressions/unicode_character_class_escape/index.md index 490e3983b54af1e..eb52b40250d807c 100644 --- a/files/en-us/web/javascript/reference/regular_expressions/unicode_character_class_escape/index.md +++ b/files/en-us/web/javascript/reference/regular_expressions/unicode_character_class_escape/index.md @@ -28,7 +28,7 @@ A **unicode character class escape** is a kind of [character class escape](/en-U ## Description -`\p` and `\P` are only supported in [unicode mode](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode). In non-unicode mode, they are [identity escapes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Escape_character) for the `p` or `P` character. +`\p` and `\P` are only supported in [unicode mode](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode). In non-unicode mode, they are [identity escapes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape) for the `p` or `P` character. Every Unicode character has a set of properties that describe it. For example, the character [`a`](https://util.unicode.org/UnicodeJsps/character.jsp?a=0061) has the `General_Category` property with value `Lowercase_Letter`, and the `Script` property with value `Latn`. The `\p` and `\P` escape sequences allow you to match a character based on its properties. @@ -44,5 +44,5 @@ To compose multiple properties, see [pattern subtraction and intersection](/en-U - [Regex reference](/en-US/docs/Web/JavaScript/Reference/Regular_expressions) - [Character class: `[...]`, `[^...]`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class) - [Character class escape: `\d`, `\D`, `\w`, `\W`, `\s`, `\S`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class_escape) -- [Escape character: `\n`, `\u{...}`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Escape_character) +- [Character escape: `\n`, `\u{...}`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape) - [Disjunction: `|`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Disjunction) diff --git a/files/en-us/web/javascript/reference/regular_expressions/word_boundary_assertion/index.md b/files/en-us/web/javascript/reference/regular_expressions/word_boundary_assertion/index.md index 2023200d2d6ff3d..51c4c4a6ab4f7b5 100644 --- a/files/en-us/web/javascript/reference/regular_expressions/word_boundary_assertion/index.md +++ b/files/en-us/web/javascript/reference/regular_expressions/word_boundary_assertion/index.md @@ -16,7 +16,7 @@ A **word boundary assertion** checks if the current position in the string is a ## Description -`\b` asserts that the current position in the string is a word boundary. `\B` negates the assertion: it asserts that the current position is not a word boundary. Both are _assertions_, so unlike other [escape characters](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Escape_character) or [escape classes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class_escape), they don't consume any characters. +`\b` asserts that the current position in the string is a word boundary. `\B` negates the assertion: it asserts that the current position is not a word boundary. Both are _assertions_, so unlike other [character escapes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_escape) or [character class escapes](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class_escape), `\b` and `\B` don't consume any characters. A word character includes the following: @@ -60,4 +60,4 @@ hasThanks("Thanksgiving is around the corner."); // false - [Input boundary assertion: `^`, `$`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Input_boundary_assertion) - [Lookahead assertion: `(?=...)`, `(?!...)`](/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookahead_assertion) - [Lookbehind assertion: `(?<=...)`, `(?