How to use the forEach function from xregexp

Find comprehensive JavaScript xregexp.forEach code examples handpicked from public code repositorys.

48
49
50
51
52
53
54
55
56
'2012-02-22'.replace(date, function(match) {
    return match.month + '/' + match.day + '/' + match.year;
}); // -> '02/22/2012'
date.exec('2012-02-22').year; // -> '2012'

// Extract every other digit from a string using XRegExp.forEach
XRegExp.forEach('1a2345', /\d/, function(match, i) {
    if (i % 2) this.push(+match[0]);
}, []); // -> [2, 4]
fork icon90
star icon165
watch icon25

35
36
37
38
39
40
41
42
43
44
    name: match[0]
  });
});

var doubleBrackets = [];
XRegExp.forEach(ret, /}\s*}/, function (match, i) {
  doubleBrackets.push({
    index: match.index,
    name: match[0]
  });
fork icon0
star icon1
watch icon2

+ 5 other calls in file