Current filter:
                                You should refresh the page.
                                  • Hello supporters,

                                    I would like to use regular expressions in TextEdit.

                                    Regular expression validation is good on site testing.

                                    But it does not work well with Devexpress control.

                                    Please check where I went wrong.

                                    Here is the regular expression:

                                    ( [1-5][0-9][0-9]|6[0-1][0-9]|62[0-1])-(0[1-9]|[1-9][0-9])-([0-6][0-9]{4})

                                    The range is as follows.

                                    ( 100~621)-(01~99)-(00001~69999)

                                    Thank you for your advice.

                                1 Solution

                                Creation Date Importance Sort by

                                Hello,

                                 
                                I see that your Regex has three groups separated by a '-' symbol. Another requirement is that the input should start from a space. Currently, your space symbol relates to the first group only. To fix it, put your space symbol into its own group, like (\s). Then, your expression will look like:

                                (\s)([1-5][0-9][0-9]|6[0-1][0-9]|62[0-1])-(0[1-9]|[1-9][0-9])-([0-6][0-9]{4})

                                Also, please not that your last group is not fully correct. For now, it matches '00000' input. To fix this, you can modify your mask this way:


                                (\s)([1-5][0-9][0-9]|6[0-1][0-9]|62[0-1])-(0[1-9]|[1-9][0-9])-(0000[1-9]|000[1-9][0-9]|00[1-9][0-9]{2}|0[1-9][0-9]{3}|[1-6][0-9]{4})

                                 

                                I have created a simple example to demonstrate this. Please try it and let me know if it helps.

                                • Changyoon Kim 12.05.2018
                                  Hello,

                                  Thank you for modifying the regular expression.
                                  The leading blank is a mistake.
                                  I have some questions.

                                  1. you set the EditMask at the designer level, set the MaskType to simple, and then modified the EditMask and MaskType at runtime. Is there a reason for doing so?

                                  2. I need to use MaskType 'Regular' instead of 'RegEx'. I learned that you should use the MaskType as a Regular in the devexpress technical documentation to use the 'SaveLiteral' property. I do not want the '-' symbol to be in the actual datatable. This is because our DB column size is NUMBER (10,0).
                                  https://www.devexpress.com/Support/Center/Question/Details/Q411567/using-regex-mask-but-not-saving-literals

                                  In other words, I want to see the '-' symbol when I edit or show it, and I want to hide the '-' symbol when saving.

                                  Of course, I can remove the '-' symbol by handling the replace method when saving, but I wonder if it can be solved at the control level.

                                  Also, in this case, is MaxLength 10 correct or 12(Contained '-' symbol) true?

                                  Thanks.
                                • Dmitry P (DevExpress Support) 12.06.2018

                                  Hi,

                                  There are no hidden reasons to modify these options at runtime. I did this just to be able to change the control behavior more rapidly without opening a designer. You can choose any of these approaches.

                                  As for your second question - in your case, MaskType.RegEx will be a better choice since you are using a full-syntax regular expression. With this approach, you can handle the ParseEditValue event as described in the Using RegEx mask but not saving literals ticket to format the result value. Then, set the MaskProperties.UseMaskAsDisplayFormat property to true if you want to keep your formatting when the control is not focused. In this case, the actual value length is 10 since it contains no '-' symbols. 
                                  I have modified the sample to show this approach. Please review it and let me know if it is exactly what are you looking for.

                                • Changyoon Kim 12.06.2018
                                  I understand your sample, I applied it to my project and it works fine.
                                  Thanks Dmitry,