Table of Contents

Class RegexMask

Namespace
MudBlazor
Assembly
MudBlazor.dll

An input mask consisting of a regular expression.

public class RegexMask : BaseMask, IMask
Inheritance
RegexMask
Implements
Derived
Inherited Members
Extension Methods

Constructors

RegexMask(string, string)

Creates a mask using a regular expression.

public RegexMask(string regex, string mask = null)

Parameters

regex string

The regular expression used to validate inputs. Must begin with ^ and end with $.

mask string

The structure of the accepted input. When null, the regular expression is used for the mask.

Remarks

The regular expression must be able to match partial inputs, must begin with ^, and must end with \(</code> to work properly (e.g. <code>^[0-9]+\)).
Consider using BlockMask to generate the regular expression automatically.

Fields

_regex

protected Regex _regex

Field Value

Regex

_regexPattern

protected string _regexPattern

Field Value

string

Properties

Delimiters

The characters which are jumped over when adding an input character.

public string Delimiters { get; protected set; }

Property Value

string

Remarks

Defaults to null. For example: for a delimiter of ., a mask of ^[0-9].[0-9].[0-9]$, and characters typed of 012, the resulting text would be 0.1.2

Methods

AlignAgainstMask(string)

Applies an input to the mask.

protected virtual string AlignAgainstMask(string text)

Parameters

text string

The text to apply to the mask.

Returns

string

The text input with any delimiters and placeholders applied.

Backspace()

Triggers a backspace at the current cursor position.

public override void Backspace()

Remarks

Has the same effect as pressing the Backspace key.

Delete()

Triggers a delete at the current cursor position.

public override void Delete()

Remarks

Has the same effect as pressing the Delete key.

DeleteSelection(bool)

Deletes the selected characters.

protected override void DeleteSelection(bool align)

Parameters

align bool

When true, the text to the right of the selection will be shifted to the left.

Email(string)

Gets a mask for email addresses.

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

Parameters

mask string

Defaults to Ex. user@domain.com. The mask to display.

Returns

RegexMask

IPv4(bool, char)

Gets a mask for IPv4 addresses with optional port masking.

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

Parameters

includePort bool

Defaults to false. When true, a port number (from 0 to 65535) is allowed.

maskChar char

Defaults to 0. The mask character for address digits.

Returns

RegexMask

IPv6(bool, char, char)

Gets a mask for IPv6 addresses with optional port masking.

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

Parameters

includePort bool

Defaults to false. When true, a port number (from 0 to 65535) is allowed.

maskChar char

Defaults to X. The mask character for address digits.

portMaskChar char

Defaults to 0. The mask character for port digits.

Returns

RegexMask

InitInternals()

Initializes this mask's characters and delimiters.

protected override void InitInternals()

InitRegex()

Initializes the regular expression.

protected virtual void InitRegex()

Insert(string)

Inserts text at the current cursor position.

public override void Insert(string input)

Parameters

input string

The characters to insert.

UpdateFrom(IMask)

Copies the mask and mask characters from the specified mask.

public override void UpdateFrom(IMask other)

Parameters

other IMask

The mask to copy from.

See Also