本帖最后由 zhangyi2013 于 2013-09-29 15:44:19 编辑

解决方案 »

  1.   

    (?=data source).*?(?=password).*?;
      

  2.   

    可以通过substring+split方法截取
      

  3.   

      Regex regx = new Regex("(?=data source).*?(?=password).*?;");
                Match match = regx.Match("metadata=res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl;provider=System.Data.SqlClient;provider connection string="data source=192.168.1.231;initial catalog=student;persist security info=True;user id=sa;password=123456;multipleactiveresultsets=True;App=EntityFramework"");
                string value = match.Value;