An attribute class for marking rich text panel handlers. It stores a regex Pattern, a Priority, and a UseCaptureGroup flag, and provides two constructors: one taking a raw pattern string and one building a pattern from start and end delimiters by escaping them and capturing the content between.
public class RichTextPanelAttribute : System.Attribute
{
public string Pattern { get; }
public int Priority { get; set; } = 0;
public bool UseCaptureGroup { get; set; } = true;
public RichTextPanelAttribute( string pattern )
{
Pattern = pattern;
}
public RichTextPanelAttribute( string startsWith, string endsWith )
{
Pattern = $"{System.Text.RegularExpressions.Regex.Escape( startsWith )}(.+?){System.Text.RegularExpressions.Regex.Escape( endsWith )}";
}
}