mardi 4 août 2015

Match sequences of n-tuples

My following C# code returns the following:

{(a,b,c),(d,e,f),(r,s,t),(u,v,y)}

{(a,b),(c,d,e)}

{(a,b),(c,d)}

But I don't want {(a,b),(c,d,e)} to be matched since the tuples inside are of different orders (2 and 3 respectively).

private void testwest()
{
    string st = "abc+{(a,b,c),(d,e,f),(r,s,t),(u,v,y)}+test-{(a,b),(c,d,e)}+rst+{(a,b),(c,d)}";
    Regex oRegex = new Regex(@"{(\(.*?\),\(.*?\))}");

    foreach (Match mt in oRegex.Matches(st))
    {
        Console.WriteLine(mt.Value);
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire