.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Regular Expressions >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Remove BB code from a given string

Posted By:Amit Mehra       Posted Date: February 13, 2015    Points: 40    Category: Regular Expressions    URL: http://www.dotnetspark.com  

This C# code example if for removing BB code from a give string using regular expression
 

Below is the Static function to remove BB code from a given string using regular expression

 

 

        public static string RemoveBBCode(string metaText)
        {
            string result = string.Empty;
            try
            {
                result = Regex.Replace(metaText, @"\[[^]]+\]", "", RegexOptions.Compiled);
                result = result.Replace("\r\n", "<br />");
            }
            catch (Exception)
            {
              throw;
            }

            return result;
        }

 


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend