try something likeusing System.Text.RegularExpressions;String s = "....";Regex re = new Regex(@"person\s+(?<person>.*?)\s+(phone\s+(?<phone>.*?)\s+)?(fax\s+(?<fax>.*?)\s+)?", RegexOptions.IgnoreCase| RegexOptions.Singleline);MatchCollection mc = re.Matches(s);
Console.WriteLine(mc.Count);
for (int i=0; i < mc.Count; i++)
{
System.Console.WriteLine("person:" + mc[i].Groups["person"]);
System.Console.WriteLine("phone:" + mc[i].Groups["phone"]);
System.Console.WriteLine("fax:" + mc[i].Groups["fax"]);
}

解决方案 »

  1.   

    thank you saucer(思归), you expression works very good in simple text, like the one i provided. but my real situation is more complex. i used the same way but failed. i am trying to study it more. 
    btw, i have a empty post for u. you can just give a simple reply. i then give you the 100 points i promised.
      

  2.   

    you are welcomeno need to give me extra points, you can delete that post to recover the points