An attribute class used to mark rich text panel handlers with a regex pattern and options. It stores a Pattern string, a Priority int, and a UseCaptureGroup bool, and provides constructors for a raw pattern or for a startsWith/endsWith pair which are escaped and combined into a regex with a capture group.
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 )}";
}
}