bradxr
8/4/2018 - 8:49 PM

Check for All or None

Specify the possible existance of an element with ? Checks for zero or one of the preceding element Think of it as saying the previous element is optional

let american = "color";
let british = "colour";
let bothRegex = /colou?r/;

bothRegex.test(american);   // returns true
bothRegex.test(british);    // returns true