How do I get my regex
\b([t][\W_]*?)+([ea][\W_]*?)+([s][\W_]*?)+([t][\W_]*?)*?\b
to hit "test", "tast" but not "teast" or "taest" with Golang?
https://regex101.com/r/ydvSR8/2
>Solution :
You can match either one or more (e[\W_]*?) or one or more (a[\W_]*?):
\b(t[\W_]*?)+((?:e[\W_]*?)+|(?:a[\W_]*?)+)(s[\W_]*?)+(t[\W_]*?)*?\b
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
See the regex demo. The ((?:e[\W_]*?)+|(?:a[\W_]*?)+) pattern is a capturing group that matches
(?:e[\W_]*?)+– one or moreeand zero or more non-alphanumeric chars as few as possible|– or(?:a[\W_]*?)+– one or moreaand zero or more non-alphanumeric chars as few as possible.