[Solved] “Cut out” a specific Text of a file and put it into a string


You can extract the keys and the values and push them into a dictionary that you can later easily access like this:

var text = "[Name]{ExampleName} [Path]{ExamplePath} [Author]{ExampleAuthor}";

// You can use regex to extract the Value/Pair
var rgx = new Regex(@"\[(?<key>[a-zA-Z]+)\]{(?<value>[a-zA-Z]+)}", RegexOptions.IgnorePatternWhitespace);
var matches = rgx.Matches(text);

// Now you can add the values to a dictionary
var dic = new Dictionary<string, string>();
foreach (Match match in matches)
{
    dic.Add(match.Groups["key"].Value, match.Groups["value"].Value);
}

// Then you can access your values like this.
var name = dic["Name"];

solved “Cut out” a specific Text of a file and put it into a string