user3523475 user3523475 - 1 month ago 9
Javascript Question

JavaScript RegEx zero or one string in bracets

I need to match a given string (let it be 'start') with possible presence of a special ending or without it. The ending could be '(a)' or '(b)' or '(c)', I mean one of letters a, b or c in braces. If there is no braces or just one brace or they are in the wrong order than there should be no match. Broke my head trying to make appropriate RegEx.
So full list of possible matches:


Any other input should produce no match.


Here it is : ^start(\([abc]\))?$

for better reading you can go to regex101

here it is what it does : enter image description here