<a href="http://www.logo8831.com/index.html?code=yes123"></a>
我要取得yes123,
现规定有个string str="http://www.logo8831.com/index.html?code=此处写正则表达式"
接着根据str来匹配出yes123
如何写这样的表达式???
我试过
string str="http://www.logo8831.com/index.html?code=(\S+)
取出的数据为yes123"></a>  多了"></a>这些。
请高手帮助,谢谢。

解决方案 »

  1.   

    或者假如你知道你的code值的范围的话code=([a-zA-Z0-9])+
      

  2.   

    code=([^>"'\s]+)code=([a-zA-Z0-9]+)
      

  3.   

    貌似
    (?<=code=)\w+(?=\")
    这样?
      

  4.   

    您可以试一下:
    string sourceString = @"<a href=""http://www.logo8831.com/index.html?code=yes123""></a>";
    string pattern = @"code=([^""]*)";
    System.Text.RegularExpressions.Match result = Regex.Match(sourceString,pattern,System.Text.RegularExpressions.RegexOptions.IgnoreCase); WL(result.Groups[1].Value);
      
    //////////////////////////////////////////////
    MSN:[email protected]请给我一个与您交流的机会!