例如:
ti.TeaID=this.textbox1.text
换成:
this.textbox1.text=ti.TeaID
P.S:如果没有“.”可以写成这样:str = Regex.Replace(str, "(\\w+\\s*)=(\\s*\\w+)", "$2 = $1");
那么现在有"."呢,怎么写?

解决方案 »

  1.   

    没必要用正则吧string test = "ti.TeaID=this.textbox1.text";
    string[] temp = test.Split('=');
    string result = temp[1] + "=" + temp[0];
      

  2.   

    如果要用正则string test = "ti.TeaID=this.textbox1.text";
    string result = Regex.Replace(test, @"([^=]*)=(.*)", "$2=$1");
      

  3.   


    那如果是:ti.TeaID=this.textbox1.text;
    换成: 
    this.textbox1.text=ti.TeaID ;
    呢?我对正则表达式不懂得
      

  4.   


    string test = "ti.TeaID=this.textbox1.text;";
    string result = Regex.Replace(test, @"([^=]*)=([^;]*)", "$2=$1");