Table of Contents

Class RegexMask

Namespace
MudBlazor
Assembly
MudBlazor.dll
public class RegexMask : BaseMask, IMask
Inheritance
RegexMask
Implements
Derived
Inherited Members
Extension Methods

Constructors

RegexMask(string, string)

Create a mask that uses a regex to restrict input.

public RegexMask(string regex, string mask = null)

Parameters

regex string

The general or progressive regex to be used for input checking.

Note: a general regex must match every possible input, i.e. ^[0-9]+$. Note: a progressive regex must match even partial input successfully! The progressive regex must start with ^ and end with $ to work correctly!

Example: to match input "abc" a progressive regex must match "a" or "ab" or "abc". The progressive regex would look like this: ^a(b(c)?)?$ or like this ^(a|ab|abc)$ It is best to generate the progressive regex automatically like BlockMask does.

mask string

The mask defining the structure of the accepted input.

Note: if not included the regex will be the mask.

Fields

_regex

protected Regex _regex

Field Value

Regex

_regexPattern

protected string _regexPattern

Field Value

string

Properties

Delimiters

Optional delimiter chars which will be jumped over if the caret is in front of one and the user inputs the next non-delimiter

public string Delimiters { get; protected set; }

Property Value

string

Methods

AlignAgainstMask(string)

Applies the mask to the given text starting at the given offset and returns the masked text.

protected virtual string AlignAgainstMask(string text)

Parameters

text string

Returns

string

Backspace()

Implements the effect of the Backspace key at the current cursor position

public override void Backspace()

Delete()

Implements the effect of the Del key at the current cursor position

public override void Delete()

DeleteSelection(bool)

protected override void DeleteSelection(bool align)

Parameters

align bool

Email(string)

Creates a predefined RegexMask for Email Address.

public static RegexMask Email(string mask = "Ex. user@domain.com")

Parameters

mask string

Set the email mask. Default is "Ex. user@domain.com"

Returns

RegexMask

IPv4(bool, char)

Creates a predefined RegexMask for an IPv4 Address with or without port masking.

public static RegexMask IPv4(bool includePort = false, char maskChar = '0')

Parameters

includePort bool

Set to true to include port to the mask.

maskChar char

Set the IPv4 maskChar. Default is '0'

Returns

RegexMask

IPv6(bool, char, char)

Creates a predefined RegexMask for an IPv6 Address with or without port masking.

public static RegexMask IPv6(bool includePort = false, char maskChar = 'X', char portMaskChar = '0')

Parameters

includePort bool

Set to true to include port to the mask.

maskChar char

Set the IPv6 maskChar. Default is 'X'

portMaskChar char

Set the IPv6 portMask. Default is '0'

Returns

RegexMask

InitInternals()

protected override void InitInternals()

InitRegex()

protected virtual void InitRegex()

Insert(string)

Inserts given text at caret position

public override void Insert(string input)

Parameters

input string

One or multiple characters of input

UpdateFrom(IMask)

public override void UpdateFrom(IMask other)

Parameters

other IMask