I need to validate some commands with the format similar to this
"/a foo.bar /b bar.foo /c 01(.01)"
where the final (.01) is optional (brackets are there to mark the contents as optional). Any digits can be set instead of the 0's and 1's. Also the switches /a, /b, /c are fixed For the moment, I've developed this regular expression:
@"/a\s*([\w\W]*)\s*/b\s*([\w\W]*)\s*/c\s*[0-9,0-9,(.,0-9,0-9){0,1}]
but for some reason, if the command is for example
"/a foo.bar /b bar.foo /c 01.",
it still validates against the regex. Valid commands should end either with 2digits.2digits or simple 2digits.
Can someone help me to get this fixed?
Cheers,
Alex Barac
Try this one:
^/a\s*(.*)\s*/b\s*(.*)\s*/c\s*((\d{2}\.\d{2})|(\d{2}))$

Debuggex Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With