We\'ve got such regexp:
var regexp = /^one (two)+ three/;
So only string like \"one two three\"
or \"one two three four\
EDIT: after you edited your post the clarify, this answer might not be relevant to your specific question. Leaving it here for reference.
Inside the regex itself, on the subject of failing quickly once you know you won't find anything:
The anchor in your regex means that once the regex engine reaches the h
of three
, it will stop looking for matches and not try to start a match on the second character. On this case, I don't think you can do better than that (but it's already linear complexity, so not so bad).
On other cases I believe you have some usual best practices to learn in order to fail as quickly as possible when you know a match can't be found anymore.
You can look at possessive quantifiers if you don't already know them, but there are many other tricks...