I have a GridControl from Devexpress. For one column of this grid is given columnedit: repositoryitemtextedit. The table contains document types and numbers. Among the types there is a birth certificate. A birth certificate has the following format:

  • Series: Roman letters (in the Latin register), two letters in Cyrillic.
  • Number: six digits
  • Example: XXXVЦФ123456

I try to set the mask as follows

repForDocNum.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Regular; repForDocNum.Mask.EditMask = "(^[XMVIL]+)\\s([А-Я]{2})\\s($\\d{6})"; 

Working works, but clumsily - when entering a table cell instead of beautiful underscores, part of this regular expression is shown.

enter image description here

The question is how to make an intelligent input mask consisting of 3 parts separated by a space.

    1 answer 1

    In general terms, the regular expression that you use as a mask is true. It is necessary to fix a few points to make it work properly.

    1. No need to use the characters start and end text (^ and $).
    2. To make it convenient to enter meta characters (for example, \ s - space), it is better to enter the @ character in front of the line. Then you will not be confused with the screening of the reverse slashes.
    3. The brackets are mainly used to group the logical parts of an expression, and not to select fragments.

    In theory, that's all. Such an expression should be obtained after corrections:

     repForDocNum.Mask.EditMask = @"[XMVIL]+[А-Я]{2}\d{6}"; 

    Pay attention to examples of regular expressions in the official DevExpress documentation: Mask Type: Extended Regular Expressions . They cover most of the popular tasks, including this one.

    • This text is displayed when focus is placed in an empty cell: _s__s______ It is better, but to hide the symbol s - Antykus
    • Apparently I misinterpreted the documentation, and \ s is not a space, but simply the insertion of the character s. See the last line in the large table from the documentation. And since you do not have spaces in the expected result, you don’t need to insert this symbol. And then the expression will be like this (I corrected the answer too): [XMVIL]+[А-Я]{2}\d{6} . - Uranus
    • Thank you so much, helped - Antykus