How can I extract some parameters from two string and populate the datagrid by them ?
I have the config.txt file and there are two strings are repeated in pairs:
set interface "ethernet1/1.271" tag 271 zone "Ntg-Gom"
set interface ethernet1/1.271 ip 192.168.9.6/30
From this two string i need in extracting ethernet1/1.271 , 271 , 192.168.9.6/30. All this for populating such datagrid:
Obviously, I need a regular expression. Now I have the regexp for one parameter (here ethernet):
StreamReader reader2 = new StreamReader(opendialog.FileName);
string patternI = @"set interface (""ethernet\S+"")";
var matchesI =
Regex.Matches(reader2.ReadToEnd(), patternI).Cast<Match>().Where(m => m.Success)
.Select(m => m.Groups[1].Value);
How to construct more complex regexp I do not know! wasting a lot of time...