mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-24 18:32:22 +00:00
docs(regex): edit u flag
This commit is contained in:
parent
bcc1d3c901
commit
8372288661
@ -134,13 +134,15 @@ codePointLength(s) // 2
|
|||||||
|
|
||||||
**(6)转义**
|
**(6)转义**
|
||||||
|
|
||||||
在没有`u`修饰符的情况下,正则中没有定义的转义(如`/\,/`)相当于没有转义(`/,/`);而在`u`模式下,这会报错。
|
没有`u`修饰符的情况下,正则中没有定义的转义(如逗号的转义`\,`)无效,而在`u`模式会报错。
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
/\,/ // /\,/
|
/\,/ // /\,/
|
||||||
/\,/u // Uncaught SyntaxError: Invalid regular expression: /\,/: Invalid escape
|
/\,/u // 报错
|
||||||
```
|
```
|
||||||
|
|
||||||
|
上面代码中,没有`u`修饰符时,逗号前面的反斜杠是无效的,加了`u`修饰符就报错。
|
||||||
|
|
||||||
## RegExp.prototype.unicode 属性
|
## RegExp.prototype.unicode 属性
|
||||||
|
|
||||||
正则实例对象新增`unicode`属性,表示是否设置了`u`修饰符。
|
正则实例对象新增`unicode`属性,表示是否设置了`u`修饰符。
|
||||||
|
Loading…
x
Reference in New Issue
Block a user