How can I accomplish the task of extracting text within tags and transform them ?
Example:
input:
[txtItalic]This is italic[/txtItalic] [txtBold] Bold Text [/txtBold]
Out: This is italic Bold Text
I'm using this code to extract the text between the tags , but the problem is that it only takes the text of the first tag
string ExtractString(string s, string tag)
{
var startTag = "[" + tag + "]";
int startIndex = s.IndexOf(startTag) + startTag.Length;
int endIndex = s.IndexOf("[/" + tag + "]", startIndex);
return s.Substring(startIndex, endIndex - startIndex);
}
What I would like to accomplish and exactly what happens in stackoverflow Editor ...
richTextBox1.SelectionFont = new Font(richTextBox1.Font, FontStyle.Bold);
richTextBox1.AppendText("Bold Text");
richTextBox1.SelectionFont = new Font(richTextBox1.Font, FontStyle.Regular);
richTextBox1.AppendText("Normal Text");
To bold text use **** and italic **