Optional Regular Expression Elements
2 answers
The whole group becomes optional, but it is all or nothing is a symbol. That way your regex will match the strings ' T'or ' Top Choice'.
Unfortunately, the regex for getting this kind of behavior is pretty ugly in nature. You will need a bunch of nested optional groups, something like the following:
/ T(o(p( (C(h(o(i(ce?)?)?)?)?)?)?)?)?/gi
, , |. , , , , , , , :
/ Top Choice?| Top Choi?| Top Ch?| Top ?| To?/gi
, ' Top Choice' ' Top Choic', ' Top Choi' ' Top Cho' .. , , .
+5