I have a text string with a custom macro:
"Some text {MACRO(parameter1)} more text {MACRO(parameter2)}"
In order to process the macro I want to split the string like that:
expected result
"Some text "
"{MACRO(parameter1)}"
" more text "
"{MACRO(parameter2)}"
I've tried to split the string using Regex.Split()
public static string[] Split(string input)
{
var regex = new Regex(@"{MACRO\((.*)\)}");
var lines = regex.Split(input)
return lines;
}
However Regex.Split() deletes the match itself and gives me the following:
actual result
"Some text "
" more text "
I know I could parse the string doing iterations of .Match()
and .Substring()
But is there an easy way get the result along with the matches?