I am working on a new feature for a C # application that processes user-defined text. This text can contain any character, but everything that is between curly brackets ({}) or between brackets ([]) will be processed in a special way (basically the text inside the brackets will be replaced for other text, and the curly brackets will display a subsection in This text will be processed differently).
So, I want to give the user the opportunity to use braces and parentheses in my text, so the first thing I thought is to use "{{" to represent "{", and the same for all other special characters, but this will give problems. If he wants to open a subsection and wants the first character in the subsection to be "{", then he would write "{{{", but this is the same thing that he would write if he wanted the character before this subsection was "{". Thus, this causes ambiguity.
Now I think I can use "\" to escape brackets and parentheses and use "\\" to represent "\". And I sort of figured out how to handle it, but I got the feeling that I'm trying to invent a wheel here. I wonder if there is a known algorithm or library that does what I'm trying to do.
source share