代码
  protected void Button3_Click(object sender, EventArgs e)
    {
        Regex reg 
= new Regex("^(?<!=http://)([\\w-]+\\.)+[\\w-]+(/[\\w-\\./?%=]*)?");
        String strURL 
= ""//txtAddress.Text;

        strURL 
= "http://www.baidu.com%22;//这个URL是以"http://"开头的.
        strURL = reg.Replace(strURL, "http://$0/");
        Response.Write(strURL
+"<BR>");  //显示结果 : http://www.baidu.com/


        strURL 
= "http://www.baidu.com/"//修改为不以"http://"开头的. 
        strURL = reg.Replace(strURL, "http://$0/");
        Response.Write(strURL);   
//显示结果 : http://www.baidu.com/ ;
    }

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2022-02-04
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2021-08-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-24
  • 2021-11-04
  • 2022-12-23
  • 2022-01-21
相关资源
相似解决方案