JavaScript RegExp - \uxxxx
描述
\uxxxx 匹配十六进制数 xxxx 指定的 Unicode 字符;例如,\u0009 与 相同。
示例
以下示例显示了 RegExp 表达式的用法。
<html> <head> <title>JavaScript RegExp</title> </head> <body> <script type = "text/javascript"> var str = "ab\u0009c"; var pattern = /\u0009/g; var index = str.search(pattern); document.write("测试 1 - 返回值: " + index); str = "abc"; index = str.search(pattern); document.write("<br/>测试 2 - 返回值: " + index); </script> </body> </html>
输出
测试 1 - 返回值: 2 测试 2 - 返回值: -1