string str bla bla bla Company xxx Parent contact account lead data Co

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
string str = "** bla ** bla ** bla Company : xxx \n\n ** \n Parent contact/account/lead data : \n Company : test \n Company Type : test type \n *** bla bla bla";
//string str = " bla bla bla \n\n ** \n Parent contact/account/lead data : \n Company : test \n Company Type : test type \n *** bla bla bla";
Regex regex = new Regex(@"Parent contact/account/lead data : [\n ]* Company : ([\w \n]+) Type : ([\w \n]+)", RegexOptions.IgnoreCase);
MatchCollection matches = regex.Matches(str);
if (matches.Count > 0)
foreach (Group group in matches[0].Groups)
{
Console.WriteLine("значение '{0}' позиция {1}",
group.Value,
group.Index);
}
Console.WriteLine("Усё");
Console.ReadLine();