I'm trying to write a simple method for removing specific BBCodes from an input string.
For example, where I have an input of:
string input = "[b]Hello World![/b]";
I would want to be able to do:
Remove(input, "b");
And get an output of:
"Hello World!"
Regex really isn't my strong suit. I've managed to piece together the following from google:
public static string Remove(string input, string code)
{
string pattern = string.Format(@"\[{0}\].*?\[\/{1}\]", code, code);
return Regex.Replace(input, pattern, string.Empty, RegexOptions.IgnoreCase);
}
Unfortunately this returns an empty string for my given example.
Can anyone advise me on how I can correct my regex to get the desired output?
Thanks