对于string 可以
string kk="fsdfsdfsd";
string vvv="http;//www.csdn.net/html/"+kk+""/4324324.htm;表示
现在有1个正则表达式为
string strReg=@"http://www.csdn.net/html/(\w+)/(\d+).htm";
我想用自定义string型为替换(\w+)那里为自定义的内容,这个正则怎么写呢?
当然
string strReg=@"http://www.csdn.net/html/"+kk+"/(\d+).htm";这样写法是错误的您的回答我将不胜感激!谢谢!

解决方案 »

  1.   

    以啥开头以啥结尾,稍微改一下
    [^\/html](\w+)(\d)$
      

  2.   

    string yourStr = "http://www.csdn.net/html/sssss/123.htm";
    ResultString = Regex.Replace(yourStr, "(http://www.csdn.net/html/)\\w+(/(\\d+).htm)", "$customerString$2";
    //resultstring = "http://www.csdn.net/html/customerString/123.htm";
      

  3.   

    string kk="fsdfsdfsd";string content = @"http://www.csdn.net/html/werqewr/123.htm";
    string strRegex = "\\w+(?=(/(\\d+).htm))";
    string strValue = Regex.Replace(content, strRegex, kk, RegexOptions.IgnoreCase);
      

  4.   

    另外,同意  mobydick(敌伯威|我排著队拿著爱的号码牌)  的方法
      

  5.   

    (?<=http://www\.csdn\.net/html/)(.*?)(?=/\d+\.htm)replace with $2