using System;
using System.Linq ;
using System.Text .RegularExpressions ;
public class Test
{
public static void Main( )
{
var lineOfKeys = "SiteElements[10].TempateElementId,SiteElements[10].TemplateElementValue,SiteElements[11].TempateElementId,SiteElements[11].TemplateElementValue" ;
var uniqueSiteElementKeys3 = Regex.Matches ( lineOfKeys, @"\b SiteElements\[[0-9]+\]" )
.Cast < Match> ( )
.Select ( match => match.Value )
.Distinct ( )
.ToList ( ) ;
foreach ( var item in uniqueSiteElementKeys3)
Console.WriteLine ( item) ;
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uTGlucTsKdXNpbmcgU3lzdGVtLlRleHQuUmVndWxhckV4cHJlc3Npb25zOwoKcHVibGljIGNsYXNzIFRlc3QKewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewoJCXZhciBsaW5lT2ZLZXlzID0gIlNpdGVFbGVtZW50c1sxMF0uVGVtcGF0ZUVsZW1lbnRJZCxTaXRlRWxlbWVudHNbMTBdLlRlbXBsYXRlRWxlbWVudFZhbHVlLFNpdGVFbGVtZW50c1sxMV0uVGVtcGF0ZUVsZW1lbnRJZCxTaXRlRWxlbWVudHNbMTFdLlRlbXBsYXRlRWxlbWVudFZhbHVlIjsKCQl2YXIgdW5pcXVlU2l0ZUVsZW1lbnRLZXlzMyA9IFJlZ2V4Lk1hdGNoZXMobGluZU9mS2V5cywgQCJcYlNpdGVFbGVtZW50c1xbWzAtOV0rXF0iKQoJCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuQ2FzdDxNYXRjaD4oKQoJCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuU2VsZWN0KG1hdGNoID0+IG1hdGNoLlZhbHVlKQoJCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuRGlzdGluY3QoKQoJCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuVG9MaXN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICBmb3JlYWNoICh2YXIgaXRlbSBpbiB1bmlxdWVTaXRlRWxlbWVudEtleXMzKQogICAgICAgIAlDb25zb2xlLldyaXRlTGluZShpdGVtKTsKCX0KfQ==