bradxr
8/4/2018 - 8:08 PM

Specify Upper and Lower Number of Matches

Can specify the upper and lower number of patterns with quantity specifiers, used with curly brackets { } Put two numbers in between

let A4 = "aaaah";
let A2 = "aah";
let multipleA = /a{3,5}h/;    // matches only if a occurs between 3 and 5 times

multipleA.test(A4);   // returns true
multipleA.test(A2);   // returns false


// specify only lower number of matches
let multipleA2 = /a{2,}h/;

// specify exact number of matches
let exact = /a{2}/;