I want to validate Winforms text box with regex.
The input sting example:
ZX1 OR N?V OR 2L? OR ?55 (any sequence of three symbols length strings with OR between them)
What is the regex that you would advise?
UPDATE:
Trying this one but seams to be it is not 100% correct
string text = "ZX1 OR N?V OR 2L? OR ?55";
Regex r = new Regex("([0-9A-Z?]{3} OR )*[0-9A-Z?]{3}");
should work in a variety of languages.
matches any non-space character, and
matches any space character, so the regex above matches any number of triplets of non-space characters separated by the string
"OR"surrounded by space characters.The
^and$serve to ensure that it matches the whole string so you can take those out if you want to find this pattern inside a larger string.