再问正则表达式:字符串"sdfsfksdf user='zhangshan' || dsf" 取得zhangshan
如题。。。
string str = "sdfsfksdf user= 'zhangshan ' || dsf "
string user = ??? //得到zhangshan
正则表达式真是件烦人的事情,改天得好好研究一把。
请高手相助一下,非常感谢!
------解决方案--------------------try..
string str = "sdfsfksdf user= 'zhangshan ' || dsf ";
string s = Regex.Match(str, "user= '([\\s\\S]+?) ' ", RegexOptions.IgnoreCase).Groups[1].Value;
Console.WriteLine(s);
------解决方案--------------------string str = "sdfsfksdf user= 'zhangshan ' || dsf ";
Regex regex = new Regex( "user= '(? <name> \\w+) ' " );
System.Text.RegularExpressions.Match m = regex.Match( str );
string str1 = m.Groups[ "name "].Value;