reg->regexp
This commit is contained in:
parent
4232a53219
commit
32e20fc97c
35 changed files with 132 additions and 132 deletions
|
@ -9,13 +9,13 @@ Now let's show that the match should capture all the text: start at the beginnin
|
|||
Finally:
|
||||
|
||||
```js run
|
||||
let reg = /^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}$/i;
|
||||
let regexp = /^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}$/i;
|
||||
|
||||
alert( reg.test('01:32:54:67:89:AB') ); // true
|
||||
alert( regexp.test('01:32:54:67:89:AB') ); // true
|
||||
|
||||
alert( reg.test('0132546789AB') ); // false (no colons)
|
||||
alert( regexp.test('0132546789AB') ); // false (no colons)
|
||||
|
||||
alert( reg.test('01:32:54:67:89') ); // false (5 numbers, need 6)
|
||||
alert( regexp.test('01:32:54:67:89') ); // false (5 numbers, need 6)
|
||||
|
||||
alert( reg.test('01:32:54:67:89:ZZ') ) // false (ZZ in the end)
|
||||
alert( regexp.test('01:32:54:67:89:ZZ') ) // false (ZZ in the end)
|
||||
```
|
||||
|
|
|
@ -8,13 +8,13 @@ Write a regexp that checks whether a string is MAC-address.
|
|||
|
||||
Usage:
|
||||
```js
|
||||
let reg = /your regexp/;
|
||||
let regexp = /your regexp/;
|
||||
|
||||
alert( reg.test('01:32:54:67:89:AB') ); // true
|
||||
alert( regexp.test('01:32:54:67:89:AB') ); // true
|
||||
|
||||
alert( reg.test('0132546789AB') ); // false (no colons)
|
||||
alert( regexp.test('0132546789AB') ); // false (no colons)
|
||||
|
||||
alert( reg.test('01:32:54:67:89') ); // false (5 numbers, must be 6)
|
||||
alert( regexp.test('01:32:54:67:89') ); // false (5 numbers, must be 6)
|
||||
|
||||
alert( reg.test('01:32:54:67:89:ZZ') ) // false (ZZ ad the end)
|
||||
alert( regexp.test('01:32:54:67:89:ZZ') ) // false (ZZ ad the end)
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue