JavaScript RegExp \xdd 元字元
示例
在字串中全域性搜尋十六進位制數字 57 (W)
let text = "Visit W3Schools. Hello World!";
let pattern = /\x57/g;
自己動手試一試 »
描述
\xdd 元字元匹配由十六進位制數字 (dd) 指定的拉丁字元。
瀏覽器支援
/\xdd/
是 ECMAScript1 (ES1) 功能。
ES1 (JavaScript 1997) 在所有瀏覽器中都得到完全支援
Chrome | Edge | Firefox | Safari | Opera | IE |
是 | 是 | 是 | 是 | 是 | 是 |
語法
new RegExp("\\xdd")
或簡單地寫成
/\xdd/
帶修飾符的語法
new RegExp("\\xdd", "g")
或簡單地寫成
/\xdd/g
正則表示式搜尋方法
在 JavaScript 中,可以使用不同的方法進行正則表示式文字搜尋。
以模式作為正則表示式,這些是最常用的方法
示例 | 描述 |
---|---|
text.match(pattern) | 字串方法 match() |
text.search(pattern) | 字串方法 search() |
pattern.exec(text) | RegExp 方法 exec() |
pattern.test(text) | RegExp 方法 test() |