Dim s As String = "[张三]xxx路xx号"
    Dim name, address As String
    Dim regex As regex = New regex("^\[(?:(?<name>[^\]]*)](?<address>.*))$", RegexOptions.IgnoreCase)
    Dim mc As MatchCollection = regex.Matches(s)
     For Each m As Match In mc
            name = m.Groups("name").Value
            address = m.Groups("address").Value     Next
结果:string name=张三;string address=xxx路xxx号

解决方案 »

  1.   

    if your string is so simple, you don't need use regular expressionstring source="[张三]xxx路xx号";
    int n = source.IndexOf('[');
    int n2 = source.IndexOf(']');string name = source.Substring(n+1,n2-n-1);
    string address = source.Substring(n2+1);
    but if you insist,System.Text.RegularExpressions.Regex re = new System.Text.RegularExpressions.Regex(@"^\[([^]]+)\](.*)$");
    System.Text.RegularExpressions.Match m = re.Match(source);
    if (m.Success)
    {
      name = m.Groups[1].Value;
      address = m.Groups[2].Value;
    }
      

  2.   

    看了好多saucer(思归)大哥的贴子了
    太崇拜saucer(思归)了