I can have 0 or many substrings within a text area in the format {key-value}Some text{/key},
For example This is my {link-123}test{/link} text area
I’d like to iterate through any items that match this pattern, perform and action based on the key and value, then replace this substring with a new string (a anchor link that is retreived by the action based on the key).
How would I achieve this in C#?
If these tags are not nested, then you only need to iterate once over the file; if nesting is possible, then you need to do one iteration for each level of nesting.
This answer assumes that braces only occur as tag delimiters (and not, for example, inside comments):