我有一些旧的.NET代码,在一个SQL字符串正则表达式(#,?,:)[a-zA-Z0-9] * _ *是什么意思?
System.Text.RegularExpressions.MatchCollection collection =
System.Text.RegularExpressions.Regex.Matches(icmd.CommandText,
"(#,?,:)[a-zA-Z0-9]*_*");
我不知道它是如何匹配的搜索参数。任何人都可以解释我?
我有一些旧的.NET代码,在一个SQL字符串正则表达式(#,?,:)[a-zA-Z0-9] * _ *是什么意思?
System.Text.RegularExpressions.MatchCollection collection =
System.Text.RegularExpressions.Regex.Matches(icmd.CommandText,
"(#,?,:)[a-zA-Z0-9]*_*");
我不知道它是如何匹配的搜索参数。任何人都可以解释我?
参考this对正则表达式有任何疑问。
在(#,?,:)[a-zA-Z0-9]*_*
1st Capturing group (#,?,:)
# matches the character # literally
,? matches the character , literally
Quantifier: Between zero and one time, as many times as possible, giving back as needed [greedy]
,: matches the characters ,: literally
[a-zA-Z0-9]* match a single character present in the list below
Quantifier: Between zero and unlimited times, as many times as possible, giving back as needed [greedy]
a-z a single character in the range between a and z (case sensitive)
A-Z a single character in the range between A and Z (case sensitive)
0-9 a single character in the range between 0 and 9
_* matches the character _ literally
Quantifier: Between zero and unlimited times, as many times as possible, giving back as needed [greedy]
方式:?它可以匹配#,,:anycharactorstring
,#,,:anycharactorstring_
,#,:anycharactorstring
,#,:anycharactorstring_____
等
感谢您的帮助 – moodym
不是解决你的问题,但我怀疑'(#,:)'节错误,应该是'[#?:]'。 – porges
是的,我认为你是对的,它可以帮助我很多 – moodym