I have a lstSubs List<KeyValuePair<string, string>
which contain value
- FNAME, "ABC"
- LNAME ,"XYZ"
- VAR001, "VAR002"
- VAR002 , "ActualValueforVAR001"
- VAR003, "VAR004"
- VAR004 , "VAR005"
- VAR005, "ActualValueforVAR003"
I have a String like envelop "Hello [FNAME] [LNAME] you have created a request for [VAR001] which got assigned to [VAR003]"
var regex = new Regex(@"\[(.*?)\]");
var matches = regex.Matches(envelop.ToString());
foreach (Match match in matches)
{
columnValue = linq to get the value from the list based on key;
envelop.Replace(match.Value, columnValue);
}
in this, The straight Key,Value pairs are easy to get via Linq but I am getting tough time to fetch the complex values which are nested in terms of connected Key, Value.
is there any way in LINQ or have to go with a loop. Expected Output : Hello ABC XYZ you have created a request for ActualValueforVAR001 which got assigned to ActualValueforVAR003
Thanks, PS. The code is not complete. it's a part of entire code edited with an intention to make it concise to issue
Edited: some of my text was not visible due to formatting. They Dictionary values are nested as I am creating them based on some conditions in which they got configured