[10,20]--{0}>=10 and {0}<=20
(10,20]--{0}>10 and {0}<=20
[10,20)--{0}>=10 and {0}<20
(10,20)--{0}>10 and {0}<20
左边是输入,右边是输出。上面这4种情况。
刚开始学正则表达式,先谢谢大家的帮助
(10,20]--{0}>10 and {0}<=20
[10,20)--{0}>=10 and {0}<20
(10,20)--{0}>10 and {0}<20
左边是输入,右边是输出。上面这4种情况。
刚开始学正则表达式,先谢谢大家的帮助
例如:拿到一个字符串"[10,20]",现在要使用正则表达式的方法,把它转换为字符串"{0}>=10 and {0}<=20",在C#中,{0}是要再输入的参数
string s1 = "";
Regex regex = new Regex(@"(\[|\()(\d+),(\d+)(\]|\))");
Match match=regex.Match(s);
if (match.Groups[1].Value == "[")
{
s1 += "{0}>=" + match.Groups[2].Value;
}
if (match.Groups[1].Value == "(")
{
s1 += "{0}>" + match.Groups[2].Value;
}
if (match.Groups[4].Value == "]")
{
s1 += " and {0}<=" + match.Groups[3].Value;
}
if (match.Groups[4].Value == ")")
{
s1 += " and {0}<" + match.Groups[3].Value;
}
Console.WriteLine(s1);try...