I was trying to write regular expression for string variable in swagger3(OAS).
The string can have multiple comma separated string. Each string's length can be between 5 and 15 and each character in a string can be either a-z or A-Z or 0-9.
I tried this one [a-zA-Z0-9]{5,15}. This one does not work as expected
For example Valid String eg
Invalid eg:
You could use:
^[a-zA-Z0-9]{5,15}(?:,[a-zA-Z0-9]{5,15})*$
Explanation
^
Start of string[a-zA-Z0-9]{5,15}
Match 5-15 chars in the range a-zA-Z0-9(?:,[a-zA-Z0-9]{5,15})*
Optionally repeat ,
and again 5-15 chars$
End of string