Regex BBCode to WYSIWYG RichText Format

AceInfinity

Emeritus, Contributor
Joined
Feb 21, 2012
Posts
1,728
Location
Canada
I seen a request by somebody else on another forum for such a thing, someone else posted code that only worked for one replacement, and did not remove the bbcode tags. Here's an example that i've created from this idea to completely format all tags within a full bit of text, and remove the bbcode:

Code:
foreach (Match match in Regex.Matches(richTextBox1.Text, @"\[b\](.*?)\[/b\]", RegexOptions.IgnoreCase).OfType<Match>().Reverse())
{
	richTextBox1.Select(match.Index, match.Length);
	Console.WriteLine(match.Groups[0]);
	richTextBox1.SelectionFont = new Font("Tahoma", 9, FontStyle.Bold);
	richTextBox1.SelectedText = match.Groups[1].Value;
}

Example:
0dEYe.gif
 
That reminds me of a bookmark that I had for stripping all HTML/Word formatting from text. It figures that I cannot find it now. The only one I can locate is http://alphabetizer.flap.tv/ which has the option to ignore reordering and make other changes to the text.
 
Yes, there's lots of cool online tools and generators out there for a limitless number of things. Cool what you can find on the internet. Thanks for sharing that Corrine :)

~Ace
 
Finding on the Internet is simple. Creating something like the BBCode stripper is another thing quite entirely. :thumbsup2:
 
I could create a reverse of what the above code does as well, Removing the formatting, or even removing BBcode from unformatted text is pretty simple :)
 

Has Sysnative Forums helped you? Please consider donating to help us support the site!

Back
Top