reg->regexp
This commit is contained in:
parent
4232a53219
commit
32e20fc97c
35 changed files with 132 additions and 132 deletions
|
@ -130,18 +130,18 @@ In the example below the regexp `pattern:[-().^+]` looks for one of the characte
|
|||
|
||||
```js run
|
||||
// No need to escape
|
||||
let reg = /[-().^+]/g;
|
||||
let regexp = /[-().^+]/g;
|
||||
|
||||
alert( "1 + 2 - 3".match(reg) ); // Matches +, -
|
||||
alert( "1 + 2 - 3".match(regexp) ); // Matches +, -
|
||||
```
|
||||
|
||||
...But if you decide to escape them "just in case", then there would be no harm:
|
||||
|
||||
```js run
|
||||
// Escaped everything
|
||||
let reg = /[\-\(\)\.\^\+]/g;
|
||||
let regexp = /[\-\(\)\.\^\+]/g;
|
||||
|
||||
alert( "1 + 2 - 3".match(reg) ); // also works: +, -
|
||||
alert( "1 + 2 - 3".match(regexp) ); // also works: +, -
|
||||
```
|
||||
|
||||
## Ranges and flag "u"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue