I would like to verify the syntax of an input field with a regex. The field should accept text like the following examples:
Something=Item1,Item2,Item3
someOtherThing=Some_Item
There has to be a word, a =
sign and a list of comma separated words. The list must contain at least one entry. So abc=
should be invalid, but abc=123
is valid.
I am using a framework which allows a regular expression (Java) to mark the input field as valid or invalid. How can I express this rule in a regex?
With the aid of https://stackoverflow.com/a/65244969/7821336, I am able to validate the comma separated list. But as soon as I prepend my stuff with the assignment, the regex does not work any longer:
(\w+)=((?:\w+)+),? // does not work!