我需要验证一个范围。输入格式如下:
string example1 = "anydate between 20100101 ~~ 20100101";
string example2 = "anydate between 20100101 and 20100101";
string example3 = "docid between 1 ~~ 2";
我正在使用以下正则表达式:
\b(\w)*(?<operator>Between|contains)\b(?<prefix>.*).*?(?<OP>~~|and)[ ]?\b(?.*)\ b
当用户输入"anydate between 20100101 ~~ 20100101 and test1"
失败时,它会捕获 until test1
。
如何使我的正则表达式不那么贪婪并且只捕获直到20100101
?