bradxr
8/4/2018 - 5:32 PM

Match Characters that Occur One or More Times

Character has to repeat consecutively (i.e. one after the other)

let regex = /a+/g;

// one occurence
let strOne = "abc";
strOne.match(regex);   // returns ["a"]

// two occurences
let strTwo = "aabc";
strTwo.match(regex);    // returns ["aa"]

// non-consecutive occurences
let strThree = "abab";
strThree.match(regex);    // return ["a", "a"]