First of all, I want extract sub-string from string between delimiters into parameters and make the string become like a string for String.Format.
Example
Source:
<Hello> [World]!
Output:
Result string
<{0}> [{1}]!
Extracted parameters in array
0: Hello
1: World
There are lots of strings which contains an unknown amount of parameter. Also, there are two types of delimiter: <>
and []
.
I searched for string extraction example using regex but most of them are base on a static string format. However, the format of string is unknown and may or may not be contain any delimiters in this case.
Edit: There is a possibility delimiter wrap by other delimiters but delimiter will always come in pair.
Example
Source:
[<Hello> World]!
Output:
Result string
[{0}]!
Extracted parameters in array
0: <Hello> World
Only outer delimiter will be considered. Anything inside should be parameters.