Hi Claude,
I just figured out how to get more than one .. tag to render. Here is my implementation:
/////////////////////////////////////
public string ProcessSpecialTags(string stringToTransform)
{
StringBuilder formattedSource = new StringBuilder();
string[] table = new string[2];
table[0] = "<b>";
table[1] = "</b>";
MatchCollection matchs;
// Look for code
//
matchs = Regex.Matches(stringToTransform, "\\[b\\](?<bold>(.|\\n)*?)\\[/b\\]", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled);
foreach (Match match in matchs)
{
// Get the formatted source code
//
formattedSource.Append(table[0]);
formattedSource.Append(match.Groups["bold"].ToString());
formattedSource.Append(table[1]);
// Update the main string
//
stringToTransform = stringToTransform.Replace(match.ToString(), formattedSource.ToString());
formattedSource.Remove( 0, formattedSource.Length );
}
return stringToTransform;
}
//////////////////////////////////////
If you need real world example of this, check out the new ASP.NET Forums Beta RC2 application, in the Components solution, goto the Components folder, and then to the Transforms.cs file. Then goto line 403 or search for: SourceCodeMarkup(string stringToTransform)
My example above was adapted from the ASP.NET Forums code.
Hope this helps everyone,
d.
|