1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
public string AttrappeChaineEntre(string orig, string debut, string fin)
{
string pattern = string.Format("({0})(.*?)({1})", debut, fin);
MessageBox.Show("Pattern "+pattern);
Regex regex = new Regex(pattern);
// while(orig.Length
// if(regex.IsMatch(orig.ToString()))
// {
// MessageBox.Show(regex.Replace(orig, "$2"));
// //return regex.Replace(orig, "$2");
// }
// return regex;
MatchCollection matches = regex.Matches(orig);
MessageBox.Show(matches.Count.ToString());
int i=2;
foreach (Match match in matches) {
//string newContent = match.Groups["$2"].Value;
MessageBox.Show(match.Groups[2].Value.ToString());
i++;
}
return "";
} |