@@ -350,7 +350,7 @@ Zero or many times. The pattern could may not occur or it can occur many times.
350
350
351
351
const pattern = / [a] . * / g // . any character, + any character one or more times
352
352
const txt = ' Apple and banana are fruits'
353
- const matches = re .match (pattern)
353
+ const matches = txt .match (pattern)
354
354
355
355
console .log (matches) // ['and banana are fruits']
356
356
@@ -383,7 +383,7 @@ console.log(matches) // ['2019']
383
383
384
384
``` js
385
385
const txt = ' This regular expression example was made in December 6, 2019.'
386
- const regex_pattern = / \d {1, 4}/ g // 1 to 4
386
+ const pattern = / \d {1,4} / g // 1 to 4
387
387
const matches = txt .match (pattern)
388
388
console .log (matches) // ['6', '2019']
389
389
```
@@ -396,7 +396,7 @@ console.log(matches) // ['6', '2019']
396
396
const txt = ' This regular expression example was made in December 6, 2019.'
397
397
const pattern = / ^ This/ // ^ means starts with
398
398
const matches = txt .match (pattern)
399
- console .log (matches) / [' This' ]
399
+ console .log (matches) // ['This']
400
400
```
401
401
402
402
- Negation
@@ -405,12 +405,12 @@ console.log(matches) / ['This']
405
405
const txt = ' This regular expression example was made in December 6, 2019.'
406
406
const pattern = / [^ A-Za-z ,. ] + / g // ^ in set character means negation, not A to Z, not a to z, no space, no coma no period
407
407
const matches = txt .match (pattern)
408
- console .log (matches) [" 6" , " 2019" ]
408
+ console .log (matches) // ["6", "2019"]
409
409
```
410
410
411
411
### Exact match
412
412
413
- It should hav ^ starting and $ which is an end.
413
+ It should have ^ starting and $ which is an end.
414
414
415
415
``` js
416
416
let pattern = / ^ [A-Z ][a-z ] {3,12} $ / ;
0 commit comments