Getting multiple values from a string with delimiters

108 Views Asked by At

I am using Scriban to render a html template from a dynamic object and a html template in the form of a string.

I am trying to validate that the dynamic object contains all the field that i need to fill into the template.

To do this, i need to find all the parts of my template, that are delimited by "{{" at the beginning and "}}" in the end.

My html template is a string, and could look like this:

"<ul id='object'>\n<h2>Name 2: {{ object.Username }}</h2>\n<h1>Message 2: {{ object.Password }}</h1>\n</ul>"

The dynamic object that fits the above html template would have to contain a Username field, and a Password field.

I would like to derive the needed parts of the string as a collection of substrings. I have been looking into Regex, but i am very green in that field, and would appreciate any help i could get.

To be totally clear, the output im looking for in the example above (the "code snippet"), is a collection of strings containing "object.Username" and "object.Password".

0

There are 0 best solutions below