[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Collapse]Data Editors
    Included Components
   [Expand]Implementation Details
   [Expand]Getting Started
   [Expand]Editor Types
   [Collapse]Common Features
    [Expand]Obtaining Editor Values
    [Expand]Binding to Data
     In-Place Mode
    [Expand]Editor Operation Modes
    [Collapse]Masked Input
      Mask Types
      Mask Type: Date-time
      Mask Type: Extended Regular Expressions
      Mask Type: Numeric
      Mask Type: Simple
      Mask Type: Simplified Regular Expressions
    [Expand]Input Validation
     Incremental Search
   [Expand]Range Control
   [Expand]Visual Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Mask Type: Simplified Regular Expressions

Note

In this mode masks use the simplified regular expression syntax, and is designed for backwards compatibility. Instead, use the RegEx mode which implements full functional regular expressions which give you more flexibility to control data input.

Simplified regular expressions don't support as many features as Extended Regular Expressions. For example, they do not support alternative valid forms for values, they also lack the auto-complete feature, etc.

In this topic:

Expanded Simplified Regular Expressions

Simplified regular expressions can be used in two cases. The first case occurs when you need to specify a custom range of characters for a specific position. The second case is when you need to provide a mask of variable length.

To construct masks using the simplified regular expressions set the editor's TextEdit.MaskType (or the TextEditSettings.MaskType for the in-place editors) property to MaskType.Regular. The mask itself should be specified using the TextEdit.Mask (or TextEditSettings.Mask) property.

A mask represents a string which can consist of metacharacters, quantifiers, special and literal characters.

Expanded Metacharacters

Metacharacters are used to represent a range of symbols. An end-user can enter text only in the positions corresponding to metacharacters. When a metacharacter is found in a specific position in the mask an end-user can enter any character from the related range in this position in the edit box. The following table lists the available metacharacters:

Character Description
. Matches any character.
[aeiou] Matches any single character included in the specified set of characters.
[^aeiou] Matches any single character, which is not included in the specified set of characters.
[0-9a-fA-F] Use of a hyphen () allows specification of contiguous character ranges.
\w Matches any word character. \w is the same as [a-zA-Z_0-9].
\W Matches any nonword character. \W is the same as [^a-zA-Z_0-9].
\d Matches any decimal digit. Same as [0-9].
\D Matches any nondigit. Same as [^0-9].

Expanded Quantifiers

These are special characters which denote the number of repetitions for the preceding character. Review the table below for the list of qualifiers and their descriptions.

Quantifier Description
* Specifies zero or more matches; for example, \w* or [a-zA-Z]*. Same as {0,}.
+ Specifies one or more matches; for example, \w+ or [a-zA-Z]+. Same as {1,}.
? Specifies zero or one matches; for example, \w? or [a-zA-Z]?. Same as {0,1}.
{n} Specifies exactly n matches; for example, [0-9]{2}.
{n,} Specifies at least n matches; for example, [0-9]{2,}.
{n,m} Specifies at least n, but no more than m, matches.

Expanded Special Characters

The following table lists the available special characters which are used to control the case of the input string and to represent various delimiters and currency symbols.

Character Description
> If a > character appears in the mask, all the characters that follow it are in uppercase until the end of the mask or until a < character is encountered.
< If a < character appears in the mask, all the characters that follow it are in lowercase until the end of the mask or until a > character is encountered.
<> If these two characters appear together in the mask, no case checking is done and the data is formatted with the case used by the end-user during data entry.
/ A / character is used to separate months, days, and years in dates. If the character that separates months, days, and years is different in the regional settings of the system that the application runs on that character is used instead.
: A : character is used to separate hours, minutes, and seconds in time values. If the character that separates hours, minutes, and seconds is different in the regional settings of the system that the application runs on that character is used instead.
$ A $ character is used to designate currency values. If the character that designates currency values is different in the regional settings of the system that the application runs on that character is used instead.

Expanded Literal Characters

A character which is not used to represent a metacharacter nor quantifier nor special character is called a literal. Literals are inserted automatically as is into the edit box in the positions defined by the mask. An end-user has no need to enter literal characters. The cursor skips over them during editing.

A symbol used to represent a reserved character can also appear as a literal if preceded by a backslash (\).

Expanded Examples

1. A mask for entering hexadecimal values of any length: [0-9A-F]*

The [0-9A-F] substring specifies that any character from the [0-9] and [A-F] ranges can be entered. The * quantifier denotes that characters from the specified range can appear an unlimited number of times.

2. A mask that requires an end-user enter at least two digits of a hexadecimal number: [0-9A-F]{2,}

If less than two digits are entered the editor will indicate that the value is not valid:

3. A mask for entering a number that has two digits in its fractional part: \d*\.\d{2}

Since the '.' character is reserved the '\.' substring is used to insert the dot as a literal into the mask.

Is this topic helpful?​​​​​​​