I am new to regex, i am trying to validate a field the user is entering weekend days in a comma separated format and using 2 characters abbreviation for the day. i developed the following pattern that is not working as i want it to:
^(fr|sa|su|mo|tu|we|th)?(?(1)(,fr|,sa|,su|,mo|,tu|,we|,th)){0,5}$
This pattern successfully matches the desired input like the following:
fr
mo
fr,sa
fr,tu
su,mo,tu,we,fr,sa
but it also matches the following wrong enteries:
fr,fr,fr,fr
sa,sa,sa,sa
I want a way to force the second group to repeat only different values included in the OR construct. is there a way regex can do that?