I have some bespoke bits of markup/tagging used within some forum posts and I am looking for a decent way to handle them (most likely using Regular Expressions, which I’m not too handy with!).
When I render the forum posts to screen, I want to convert the bespoke tagging within the text, converting them into real tags. There could well be multiple instances of each bespoke tag within a post that needs to be handled.
Here are the examples I need to handle:
[URL=http://www.mysite.com]anchor text[/URL]
[URL=www.mysite.com]anchor text[/URL]
Needs to be replaced with:
<a href="http://www.mysite.com">anchor text</a>
[EMAIL=me@mysite.com]anchor text[/EMAIL]
Needs to be replaced with:
<a href="mailto:me@mysite.com">anchor text</a>
[IMG]http://www.mysite.com/image.jpg[/IMG]
[IMG]www.mysite.com/image.jpg[/IMG]
Needs to be replaced with:
<img src="http://www.mysite.com/image.jpg" />
[QUOTE=username]quoted text[/QUOTE]
Needs to be replaced with:
<div class="quote"><h3>Posted by: username</h3>quoted text</div>
check out Convert BBCode to HTML – C# – Source Code | DreamInCode.net