JavaScript RegExp \udddd character

Definition and usage

\udddd The character matching is determined by the hexadecimal number (dddd) defined by the Unicode character.

Example

Perform a global search for the hexadecimal number 0057 (W) in the string:

let text = "Visit CodeW3C.com. Hello World!";
let pattern = /\u0057/g;

Try it yourself

Syntax

new RegExp("\\udddd)

or abbreviated as:

/\udddd/

Syntax with modifiers

new RegExp("\\udddd", "g")

or abbreviated as:

/\udddd/g

Browser support

/\udddd/ It is an ECMAScript1 (ES1) feature.

All browsers fully support ES1 (JavaScript 1997):

Chrome IE Edge Firefox Safari Opera
Supports Supports Supports Supports Supports Supports

Regular expression search methods

In JavaScript, regular expression text search can be completed using different methods.

UsagePattern (pattern)As regular expressions, these are the most commonly used methods:

example description
text.match(pattern) 字符串方法 match()
text.search(pattern) 字符串方法 search()
pattern.exec(text) RexExp 方法 exec()
pattern.test(text) RexExp Method test()