I greet you, SW. community!
Recently, I had the task to implement some parser (although this term is not very suitable) of textual information, which may contain not only markup (for example, Markdown is used here), but also certain commands.
With markup, everything is clear, for each markup block we write something like that (I don’t already remember where I found this code, but it works amazingly well):
new RegexFormatter(@"\[url=((.|\n)*?)(?:\s*)\]((.|\n)*?)\[/url(?:\s*)\]", "<a href=\"$1\" target=\"_blank\">$3</a>")); Then we loop through all the patterns for the whole text and perform the conversion (if you tell me a more optimal way, I will be grateful too).
But what to do if the text can contain commands that should perform interaction with the database, or any other logic? Suppose I am writing a self-hosted site console . How to find them in the text, how to determine which command in the text executes which command in the programming language?
Of course, I can write a kind of bicycle in the forehead, but I would like to understand how to do it correctly. Who can prompts, or at least throws the literature?
Thanks in advance!
UDP: clarified the question a bit.