字符串:<br/>UserName:&nbsp;&nbsp;AV-6009034<br/>Password:&nbsp;&nbsp;61fxe72opj<br/><br/>UserName:&nbsp;&nbsp;AV-5974303<br/>Password:&nbsp;&nbsp;p9stc1r5vb<br/><br/>UserName:&nbsp;&nbsp;AV-6016790<br/>Password:&nbsp;&nbsp;95hh667r9a<br/><br/>
希望得到的结果:
m.Groups[0].Value:UserName:   AV-6009034
Password:   61fxe72opjm.Groups[1].Value:UserName:   AV-5974303
Password:   p9stc1r5vb
................

解决方案 »

  1.   

    能把读取所有的“UserName:&nbsp;&nbsp;AV-6009034<br/>Password:&nbsp;&nbsp;61fxe72opj”就好了,格式后续处理,谢谢
      

  2.   

    UserName:(&nbsp;){2}(?<UserName>AV-\d{7})\<br/\>+Password:(&nbsp;){2}(?<Password>[\w\d]{10})
    m.Group["UserName"]
    m.Group["Password"]
      

  3.   

    trystring test = "<br/>UserName:&nbsp;&nbsp;AV-6009034<br/>Password:&nbsp;&nbsp;61fxe72opj<br/><br/>UserName:&nbsp;&nbsp;AV-5974303<br/>Password:&nbsp;&nbsp;p9stc1r5vb<br/><br/>UserName:&nbsp;&nbsp;AV-6016790<br/>Password:&nbsp;&nbsp;95hh667r9a<br/><br/>";
    test = test.Replace("&nbsp;", " ");
    test = test.Replace("<br/>", "\n");
    MatchCollection mc = Regex.Matches(test, @"UserName:\s+\S+\s*Password:\s+\S+", RegexOptions.IgnoreCase);
    foreach (Match m in mc)
    {
        richTextBox2.Text += m.Value + "\n\n";
    }