I am trying to write a regular expression to match "ismU" flags. The requirements are as follows: 1) each character appears at most only once 2) The character can appear in any order: "is", "si", "mi", "smi", "Uims"
The requirement 1) lead to "?" quantifier, and 2) leads to "|" alternation.
"i?|U?|m?|s?" could only apply to length of 1.
"[imsU]{1,4}" could apply to length of 4 but it accepts duplicated flag(e.g., "ii")
Test cases to be True:[ "i", "im", "mi", "Ums", "iUsm"]; Test cases to be False:[ "I", "mm"].