正则表达式在双引号之间获取文本表单字符串,其中至少包含任何一个
:=, &&, ||, ==, <, >, <=, >=, <>, &, +, -, *, /, ? .
代码:
script = "if(a<=b, strcat(\" userid <= 'tom' \",\" and test = 1\", \" and test >= 10 \"), nop());";
string tempScript = (script ?? "").Trim();
var functionMatches = Regex.Matches(tempScript, @"Some RegEx");
if (functionMatches != null && functionMatches.Count > 0)
{
foreach (Match fm in functionMatches)
{
Console.WriteLine(fm.Value);
}
}
Console.ReadLine();
例如:
Input :-
"if(a<=b, strcat(" userid <= 'tom' "," and test = 1", " and test >= 10 "), nop());"
Output :-
1) " userid <= 'tom' "
2) " and test >= 10 "
谢谢。