-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlesson06.js
41 lines (31 loc) · 950 Bytes
/
lesson06.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// regex
// /pattern/modifiers;
var regex = /que/ig
var a = ['Que estamos haciendo?', 'Porque lo hacemos?', 'Quien hace esto?']
a.forEach(function (element) {
var match = element.match(regex)
if ((match !== null) && (match.length > 0)) {
console.log(element + ' it\'s a Match')
}
}, this)
var b = ['Que estamos haciendo?', 'Porque lo hacemos?', 'Quien hace esto que?']
b.forEach(function (element) {
var match = element.search(regex)
if (match > -1) {
console.log(element + 'at position ' + match)
}
}, this)
var regex2 = /[^qdfaeg]/ig
b.forEach(function (element) {
var match = element.match(regex2)
if ((match !== null) && (match.length > 0)) {
console.log(element + 'not matching ' + match)
}
}, this)
var regex3 = /[qdfaeg]/ig
b.forEach(function (element) {
var match = element.match(regex3)
if ((match !== null) && (match.length > 0)) {
console.log(element + 'not matching ' + match)
}
}, this)