C#中如何取某字符串"("之前的字符。注意:"("之前或之后字符长短都不固定。谢谢!
比如某字符串为: 4545tews(3545435) 取"("之前的字符为:4545tews

解决方案 »

  1.   

     string aaaa = "aaaaaaaaaaaaa(1111)";            string[] _Temp = aaaa.Split('(');
      

  2.   

    s= s.Substring(0, s.index("("));
      

  3.   

    string s = "4545tews(3545435)";string result = s.SubString(0, s.IndexOf('(');
      

  4.   


    string s = "4545tews(3545435)";
    string ss = s.SubString(0,s.indexof("("));
      

  5.   


                string s = "4545tews(3545435)";            string result = s.Substring(0, s.IndexOf('('));
      

  6.   

    string str= str.Substring(0, str.IndexOf('('));
    或用正则表达式
      

  7.   

    string s = "4545tews(3545435)";string result = s.SubString(0, s.IndexOf('(');
      

  8.   

    string n = "4545tews(3545435)"; 
     string p= n.SubString(0,n.indexof('(')); 
      

  9.   

    C#从无规律的字符串中取其子字符串的问题http://topic.csdn.net/u/20081224/10/0d99782b-9085-4d78-a81d-f2c7ade6e183.html
      

  10.   

    还没有写完吧!!!
    括号之前的 应该再加上string strResult=_Temp[0];
      

  11.   

                string zzz = "12235005(501535545)";            string gggg= zzz.Substring(0, zzz.IndexOf('('));
      

  12.   

    1-
    string aaaa = "aaaaaaaaaaaaa(1111)";             string[] _Temp = aaaa.Split('(');
    2- 正则表达式
      

  13.   


    GroupCollection gc = Regex.Match(str,"(\w*)\((\w*)").Groups;
    string preStr = gc[1].Value;  //左括号前的部分
    string nextStr = gc[2].Value; //左括号后的部分