我在前台传入sql的条件诸如:aaa>'100' and bbb<='200'
aaa和bbb是两个字段名
我在后台获取到这个条件后,还想获取这两个字段名,请问从上面:aaa>'100' and bbb<='200'这个字符串中该如何截取?谢谢大家
aaa和bbb是两个字段名
我在后台获取到这个条件后,还想获取这两个字段名,请问从上面:aaa>'100' and bbb<='200'这个字符串中该如何截取?谢谢大家
解决方案 »
- RationalRoseEnterprise建模是否支持c#啊?再问问建模的相关问题,先感谢了!
- dd/MM/yyyy格式化日期为什么会变成dd-MM-yyyy?
- C#做的windows程序!菜鸟求助!学生管理
- (dropdownlist)SelectedItem.Text.的value和text的区别问题
- 100分,求怎样冻结DataGrid中最左边一列?
- 紧急!请各位高手进来帮帮忙,一个与活动目录相关的问题?
- WCF,请看下这个配置
- 帮我看看这点代码哪点有问题。。。
- 在一个.cs中如何调用其他.cs
- 请问在listview中怎样判断mouse是单击还是双击?
- c#progressBar到头后,怎样重新开始
- 对Aspx页面的body怎么加样式?
string bbb
string sql;
sql= aaa+"<100 and "+bbb+">100"
string bbb="bbb";
string sql;
sql= aaa+"<100 and "+bbb+">100"
然后你想怎么拿都可以
{
Match res = Regex.Match(strSentence, @"(?<=[<>=]+?')\d+\.?\d*(?=')");
if (res.Success)
{
if (double.TryParse(res.Value,out outCondition))
{
return true;
}
}
outCondition = 0;
return false;
}然后使用方法如下:
string strSource = "aaa>'100' and bbb<='200'";
double dCondition;
if (GetCondition(strSource, out dCondition))
{
//dCondition可以用了
}
前台 *.aspx?condition=aaa>'100' and bbb<='200';
后台 string x=request.querystring["condition"]
就是说我想从x中获取出aaa和bbb来。就是上面sql条件的字段名
public static bool GetCondition(string strSentence,string strField, out double outCondition)
{
Match res = Regex.Match(strSentence, @"(?<=" + strField + @"[<>=]+?')\d+\.?\d*(?=')",RegexOptions.IgnoreCase);
if (res.Success)
{
if (double.TryParse(res.Value,out outCondition))
{
return true;
}
}
outCondition = 0;
return false;
}使用:
private void button5_Click(object sender, EventArgs e)
{
string strSource = "aaa>'100' and bbb<='200'";
double dCondition;
if (GetCondition(strSource,"aaa", out dCondition))
{
dCondition++;
}
if (GetCondition(strSource, "BBB", out dCondition))
{
dCondition++;
}
}
前台 *.aspx?condition=aaa>'100' and bbb<='200';
后台 string x=request.querystring["condition"]
就是说我想从x中获取出aaa和bbb来。就是上面sql条件的字段名
如果从*.aspx?condition=aaa>'100' and bbb<='200';
获取到
aaa>'100' and bbb<='200'
那你可以这样作
string strAspCode = @"*.aspx?condition=aaa>'100' and bbb<='200';";
Match result = Regex.Match(strAspCode,@"(?<=condition=)[^;]+?(?=;)");
if(result.Success)
{
MessageBox.Show(result.Value);
}