Archive Browser
Download cyotek.web.bbcodeformatter.zip, last updated 18/03/2010 (7.12 KB)
Download- md5: e33d27a1760bd48f92ea2556322c392f
using System.Text.RegularExpressions;
namespace Cyotek.Web.BbCodeFormatter
{
internal class RegexFormatter : IHtmlFormatter
{
#region Private Member Declarations
private Regex _regex;
private string _replace;
#endregion Private Member Declarations
#region Public Constructors
public RegexFormatter(string pattern, string replace)
: this(pattern, replace, true)
{ }
public RegexFormatter(string pattern, string replace, bool ignoreCase)
{
RegexOptions options;
options = RegexOptions.Compiled;
if (ignoreCase)
options |= RegexOptions.IgnoreCase;
_replace = replace;
_regex = new Regex(pattern, options);
}
#endregion Public Constructors
#region Public Virtual Methods
public virtual string Format(string data)
{
return _regex.Replace(data, _replace);
}
#endregion Public Virtual Methods
#region Protected Properties
protected Regex Regex
{ get { return _regex; } }
protected string Replace
{ get { return _replace; } }
#endregion Protected Properties
}
}
Donate
This software may be used free of charge, but as with all free software there are costs involved to develop and maintain.
If this site or its services have saved you time, please consider a donation to help with running costs and timely updates.
Donate