I want a string, which must be in parentheses () and separated with a comma , something like: (aaa),(bbbb),(cccccccc)
How could I match that using regular expression?
You can try this
^(?!,)(,?\(\w+\))+$
^ marks the beginning of string
$ marks the end of string
Both ^,$ are required else it would match in between
\w+ matches 1 to many of [a-zA-Z\d_]
,? would optionally match ,
^(?!,) would look for , at the beginning of string and if it finds it,it doesn't match further.If it doesn't find,it returns to the previous position i.e at the start of string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With