1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 10:22:23 +00:00

Update regex.md

This commit is contained in:
龙腾道 2019-09-14 22:34:42 +08:00 committed by GitHub
parent 10338972d5
commit fa183748b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -132,6 +132,15 @@ codePointLength(s) // 2
上面代码中,不加`u`修饰符,就无法识别非规范的`K`字符。
**6转义**
在没有`u`修饰符的情况下,正则中没有定义的转义(如`/\,/`)相当于没有转义(`/,/`);而在`u`模式下,这会报错。
```javascript
/\,/ // /\,/
/\,/u // Uncaught SyntaxError: Invalid regular expression: /\,/: Invalid escape
```
## RegExp.prototype.unicode 属性
正则实例对象新增`unicode`属性,表示是否设置了`u`修饰符。