We\'ve got such regexp:
var regexp = /^one (two)+ three/;
So only string like \"one two three\" or \"one two three four\
I think there is no automatic "Apply to every Pattern"-Solution. However you can manually derive an "optional" pattern out of your regex, and check against both patterns:
var fullPattern = /^one (two)+ three/;
var optPattern = /^o?n?e? ?(t?w?o?)+ ?t?h?r?e?e?$/;
//verbal
if (fullPattern.matches()){
//matched
} else {
if (optPattern.matches()){
//looks promising
}else{
//no match.
}
}
You could also implement your own optionalizePattern() method, that converts Regex Pattern into such an Optional derivate. (Will be a difficult task to cover ALL possible patterns. Dunno, if possible at all.)