File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -483,7 +483,7 @@ regexArrows.test('←↑→↓↔↕↖↗↘↙⇏⇐⇑⇒⇓⇔⇕⇖⇗⇘
483
483
484
484
## v 修饰符:Unicode 属性类的运算
485
485
486
- 有时,需要向某个 Unicode 属性类添加或减少字符,即需要对属性类进行运算。现在有一个 [ 提案 ] ( https://github.com/tc39/proposal-regexp-v-flag ) , 增加了 Unicode 属性类的运算功能。
486
+ 有时,需要向某个 Unicode 属性类添加或减少字符,即需要对属性类进行运算。[ ES2024 ] ( https://github.com/tc39/proposal-regexp-v-flag ) 增加了 Unicode 属性类的运算功能。
487
487
488
488
它提供两种形式的运算,一种是差集运算(A 集合减去 B 集合),另一种是交集运算。
489
489
@@ -516,6 +516,22 @@ regexArrows.test('←↑→↓↔↕↖↗↘↙⇏⇐⇑⇒⇓⇔⇕⇖⇗⇘
516
516
[\p{Emoji}-- \p{ASCII }]
517
517
```
518
518
519
+ 看一个实际的例子,` 0 ` 属于十进制字符类。
520
+
521
+ ``` javascript
522
+ / [\p {Decimal_Number}] / u .test (' 0' ) // true
523
+ ```
524
+
525
+ 上面示例中,字符类是 Unicode 专用的,所以必须使用` u ` 修饰符。
526
+
527
+ 如果把` 0-9 ` 从十进制字符类里面去掉,那么` 0 ` 就不属于这个类了。
528
+
529
+ ``` javascript
530
+ / [\p {Decimal_Number}-- [0-9 ] ]/ v .test (' 0' ) // false
531
+ ```
532
+
533
+ 上面示例中,` v ` 修饰符只能用于 Unicode,所以可以省略` u ` 修饰符。
534
+
519
535
## 具名组匹配
520
536
521
537
### 简介
You can’t perform that action at this time.
0 commit comments