string str = "测试二||312000100036515&&&服务器测试1||180183852208510&&&";
int index1 = str.IndexOf("||")+2;
int index2 = str.IndexOf("&&&");
string value = string.Empty;
if (index1 >= 0 && index2 > index1)
value = str.Substring(index1, index2 - index1);

解决方案 »

  1.   


    @"^[^\|]*\|\|(?<m>[^\|\&]*)"Groups["m"];
      

  2.   

                String sru="测试二||312000100036515&&&服务器测试1||180183852208510&&&";
                String tpm = sru.Substring(sru.IndexOf("||")+2);
                String tpm2 = tpm.Substring(0,tpm.IndexOf("&&&"));
                textBox2.Text = tpm2;
               
      

  3.   


    @"(?<=^[^|]+\|\|)[^&]+"  //这样就可以了
      

  4.   

            String str="测试二||312000100036515&&&服务器测试1||180183852208510&&&";
            Regex objRegex = new Regex(@"(?<=\w+||)\d+(?=&&&)");
            MatchCollection objMatches = objRegex.Matches(str);
            foreach (Match objMatch in objMatches)
            {
                Response.Write(objMatch.Value + "<br/>");
                
            }
            //312000100036515
            //180183852208510