[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Collapse]Editors and Simple Controls
   [Collapse]Simple Editors
    [Expand]Included Components
    [Expand]Editors Structure
    [Collapse]Editors Features
      Text Editing Overview
     [Collapse]Input Mask
       Mask Type: Numeric
       Mask Type: Date-time
       Mask Type: Extended Regular Expressions
       Mask Type: Simple
       Mask Type: Simplified Regular Expressions
     [Expand]Format and Parse Editor Values
     [Expand]Editor Buttons
     [Expand]Dropdown Editors Overview
      Image Editing Menu
     [Expand]Data Binding Overview
     [Expand]Appearance Customization
     [Expand]Miscellaneous Features
    [Expand]Member Tables
    [Expand]Examples
   [Expand]Lookup Editors
   [Expand]Token Edit Control
   [Expand]Breadcrumb Edit Control
   [Expand]Range Control
   [Expand]Image Slider
    Camera Control
    Templated ListBox Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[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]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Mask Type: Extended Regular Expressions

Extended regular expressions allow you to specify a pattern that the entered text should match. The syntax is similar to the syntax defined in the POSIX ERE specification.

Note

Run the XtraEditors demo to try out input masks.

Tip

To allow users to enter numeric or date-time values you can also use the numeric and date-time mask types.

Expanded Mask Type and Mask Expression

The RepositoryItemTextEdit.Mask property provides access to a MaskProperties class instance that specifies an input mask. Set the MaskProperties.MaskType property to MaskType.RegEx to enable the regex mask format. Use the MaskProperties.EditMask property to specify the mask expression.

Expanded Metacharacters

Metacharacters specify characters users can enter at the corresponding positions. The table below lists the available metacharacters.

Character

Description

.

Any character.

[aeiou]

Any single character from the specified character set.

[^aeiou]

Any single character not from the specified character set.

[0-9a-fA-F]

Any single character from the specified character range.

\w

Any single alphanumeric character. The same as [a-zA-Z_0-9].

\W

Any single non-alphanumeric character. The same as [^a-zA-Z_0-9].

\d

Any single numeric character. The same as [0-9].

\D

Any single non-numeric character. The same as [^0-9].

\s

Any single whitespace (space, tab, etc.).

\S

Any single non-whitespace character.

\x00, where 00 is an ASCII character code (two digits).

An ASCII character. For example, [\x40] stands for '@'.

\uFFFF, where FFFF is a Unicode character code (four digits).

A Unicode character. For example, [\u00E0] stands for 'à'.

\p{category}, where category is a Unicode character category name.

Any character from the specified Unicode character category. For example, \p{Lu} stands for an uppercase letter. The following Unicode categories are available:

Letter (L) - any letter.

UppercaseLetter (Lu) - an uppercase letter. Entered characters are converted to uppercase.

LowercaseLetter (Ll) - a lowercase letter. Entered characters are converted to lowercase.

Number (N) - any number.

Symbol (S) - a mathematical symbol, currency symbol, or a modifier symbol.

Punctuation (P) - any punctuation mark.

Separator (Z) - any separator.

See System.Globalization.UnicodeCategory for information on other categories.

\P{category}, where category is a Unicode character category name.

Any character not from the specified Unicode character category.

\R.

A character that separates a number's integer and fractional parts. The culture's System.Globalization.NumberFormatInfo.NumberDecimalSeparator property specifies the actual character.

\R:

A character that separates hours, minutes, and seconds. The culture's System.Globalization.DateTimeFormatInfo.TimeSeparator property specifies the actual character.

\R/

A character that separates months, days, and years. The culture's System.Globalization.DateTimeFormatInfo.DateSeparator property specifies the actual character.

\R{character}, where character is a character name.

The specified character. For example, \R{CurrencySymbol} stands for the culture's currency symbol. The following character names are available:

DayNames - a culture-specific full weekday name. The culture's System.Globalization.DateTimeFormatInfo.DayNames property specifies day names.

MonthNames - a culture-specific full month name. The culture's System.Globalization.DateTimeFormatInfo.MonthNames property specifies month names.

AbbreviatedDayNames - a culture-specific abbreviated weekday name. The culture's System.Globalization.DateTimeFormatInfo.AbbreviatedDayNames property specifies abbreviated day names.

AbbreviatedMonthNames - a culture-specific abbreviated month name. The culture's System.Globalization.DateTimeFormatInfo.AbbreviatedMonthNames property specifies abbreviated month names.

AMDesignator - the string designator for hours that are "ante meridian" (before noon). The culture's System.Globalization.DateTimeFormatInfo.AMDesignator property specifies the actual character.

PMDesignator - the string designator for hours that are "post meridian" (after noon). The culture's System.Globalization.DateTimeFormatInfo.PMDesignator property specifies the actual character.

DateSeparator - the date separator. The same as \R/. The culture's System.Globalization.DateTimeFormatInfo.DateSeparator property specifies the actual character.

TimeSeparator - the time separator. The same as \R:. The culture's System.Globalization.DateTimeFormatInfo.TimeSeparator property specifies the actual character.

NumberDecimalSeparator - the decimal separator in numeric values. The same as \R.. The culture's System.Globalization.NumberFormatInfo.NumberDecimalSeparator property specifies the actual character.

CurrencyDecimalSeparator - the decimal separator in currency values. The culture's System.Globalization.NumberFormatInfo.CurrencyDecimalSeparator property specifies the actual character.

CurrencySymbol - the currency symbol. The culture's System.Globalization.NumberFormatInfo.CurrencySymbol property specifies the actual character.

NumberPattern - any numeric value in the culture's number format. The culture's System.Globalization.CultureInfo.NumberFormat property provides access to number pattern settings.

CurrencyPattern - any currency value in the culture's currency format (without the currency symbol). The culture's System.Globalization.CultureInfo.NumberFormat property provides access to currency pattern settings.

Any other character.

Any other character that is not a metacharacter, quantifier, or special character specifies itself. For example, a allows users to enter "a".

To allow users to enter a special character, precede it with a backslash. For example, \* allows users to enter '*'. \\ allows users to enter '\'.

Expanded Quantifiers

Quantifiers follow a metacharacter and specify how many times the character should be repeated. The table below lists available qualifiers.

Quantifier Description Samples
* Zero or more matches. \w* - zero or more letters. The same as \w{0,}.
+ One or more matches. \w+ - one or more letters. The same as \w{1,}.
? Zero or one matches. \w? - zero or one letter. The same as \w{0,1}.
{n} Exactly n matches. \d{4} - four digits.
{n,} At least n matches. \d{2,} - two or more digits.
{n,m} At least n, but no more than m matches. \d{1,3} - one, two, or three digits.

Expanded Special characters

Special characters allow you to group expression parts and provide alternatives. The table below lists the available special characters.

Character

Description

Samples

|

Alternate several expressions.

1|2|3 - "1", "2", or "3".

abc|123 - "abc", or "123".

\d{2}|\p{L}{2} - two digits or two letters.

(, )

Groups several characters into a single unit.

(an|ba)t - "ant" or "bat".

(net)+ - "net", "netnet", "netnetnet", and so on. Compare with net+ - "net", "nett", "nettt".

(0|1)+ - a string of indeterminate length consisting of "0" or "1".

Expanded Precedence

The order of precedence is as follows:

  1. Escaped Characters: \. Sets: [].
  2. Grouping: ().
  3. Quantifiers: *, +, ?, {}.
  4. Concatenation.
  5. Alternation: |.

Expanded Examples

Example 1

\d+(\R.\d{0,2})? - numeric values with or without the fractional part.

\d+ stands for any number of decimal digits. \R. - the decimal point. \d{0,2} - 0, 1 or 2 digits. ( )? - the inner expression appears only once.

Example 2

(1?[1-9])|([12][0-4]) - numbers in the range of 1-24.

| alternates (1?[1-9]) and ([12][0-4]). The first part matches numbers in the ranges of 1-9 and 11-19. The second part matches numbers in the ranges of 10-14 and 20-24.

Expanded See Also

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