.NET MAUI Regex Mask
To validate the user input as a standard (alphanumeric) user input against a regular expression, use the RegexMaskedEntry
, which provides errors if the regular expression (regex) rule is not matched. The resulting value is a string.
Regex | Usage |
---|---|
"[0-9]" |
a single digit |
"[0-9]{1}" |
a single digit (required) |
"[a-zA-Z]" |
a single letter |
"[a-zA-Z]{1}" |
a single letter (required) |
"\S" |
all symbols without space |
"." |
all symbols |
"[0-9a-zA-Z]" |
all without special symbols and space |
"[0-9a-zA-Z ]" |
all without special symbols |
The following example demonstrates how to set the RadRegexMaskedEntry
:
<telerik:RadRegexMaskedEntry x:Name="regexMaskedEntry" Mask="^[a-z]$" Placeholder="^[a-z]$" AutomationId="regexMask"/>
The image below shows the end result.
For the MaskedEntry Regex Mask examples, go to the SDKBrowser Demo Application and navigate to MaskedEntry -> Mask Types category.