I have tried following regexp in cpp ^((T[X-Z]|R[X-Z])+?)(?:,\\s*|$)
. It validates only TX. If empty string it should be invalid, it should not accept numbers as well
User may enter:
It should be valid in all cases.
For the test cases that you put here,([TR][XYZ])(,( )?)?
might work.
I have tested it for you here (Mention that global
and multiline
flags are enabled)