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
| private void button1_Click(object sender, EventArgs e)
{
string txt = textBox1.Text;
string regexp = @"[^:]*\s([0-9]+)\|([0-9]+)@[^\[]*\[([0-9]+)\|([0-9]+)[\[\w]*";
string result = string.Empty;
Regex rg = new Regex(regexp);
// code
if (rg.IsMatch(txt))
{
int cpt = 0;
foreach (Group g in rg.Match(txt).Groups)
{
if (cpt > 0)
{
result += "\r\nGROUP " + cpt.ToString() + "\r\n";
foreach (Capture c in g.Captures)
{
result += c.Value + "\r\n";
}
}
cpt++;
}
}
label1.Text = result;
} |
Partager