I have an alphanumeric string(M-T-D-S-F1-F2), I need to make sure that a combination of alnum (F1) exists only once in the string.
Example String: M-T-D-S-F1-F2
The regex i am using is /^[^F1]*F1?[^F1]*$/
M-T-D-S-F1 -> Matches
M-T-D-S-F1 F -> Doesn't match (Since it is not matching F1 literally)
M-T-D-S-F1 F2 -> Doesn't match
The problem is the regex fails with F2 present. I need to consider F1 as a combination and match literally.
How can i do that?