could someone help me to create a posix regex which checks if the entered string follows the following pattern:
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
Or
Monday, Wednesday, Friday
Or
Sunday
Then:
- Days of the week followed by ", "
- I can't repeat a day of the week
- The last day of a string must not have ", "
If the order of days doesn't matter, use:
See demo here.
Explanation:
^matches the begin of the string.$matches the end of the string.(?!$)means that comma must not be follwed by the end of string.(?!.*\2)means not followed by any number of characters (.*) and the second group (\2), that is the innermost one.About the last point, I suggest you to google about regex matching groups, lookarounds backreferences