c# - Implement Date Time Picker functionality with MaskedTextBox. Validation done with RegEx -
I am trying to create a custom control specifically for my application which prohibits the input data entered Will use the masked textbox for.
Now I want to implement it in C #.
Class CustomDateMask: System.Windows.Forms.MaskedTextBox this.Mask = "00/00/2 \ 000"; For the year 2000 and above, the date format is "dd / mm / yyyy". Type of verification = type (system. Datam);
I have seen a regular expression to validate my date by limiting the date by leaving the entry and capturing the events of the Capperes.
Now my RegExp is going to be like this
string regaire = @ "(200 [8 9] | 201 [0-9])"; // If this is incorrect for the year from 2008-2019, then correct this RegEx. String regMonth = @ "(0 [1- 9] | 1 [012])"; String regDate = @ "(0 [1-9] | [12] [0- 9] | 3 [01])"; String separator = @ "[- /]"; String ddmmyyyy = regDate + seperator + regMonth + separator + regair;
I saw a regarding the regular expression for the date format check. Now I want to use this code in C # which I gave you in the link given above. This code is written in pearl
and I want to have the same functionality in C #. But I do not know how to remove the date, month, year from this regular expression extracted in the examples given below. $ 1, $ 2, $ 3 to
sub-defined {my $ input = shift; If ($ input = ~ m! ^ ((?? | 19 | 20) \ d \ d) [- /.](0] [1-9] [1] [2] [2] [2] [2] ] [] - /.](0 [1] 9] | [12] [0-9] | 3 [01]) $!) {# At this point, $ 1 entered the year, $ 2 months and $ 3 Are kept on the date of the date ($ 3 ==31 and ($ 2 == 4 or $ 2 == 6 or $ 2 == 9 or $ 2 == 11)) {return 0; one month with 30 days Alsuf ($ 3> = 30 and $ 2 == 2) {return 0; # 30th or 31st} ALLECIF ($ 2 == 2 and $ 3 == 29 and not ($ 1% 4) == 0 and ($ 1% 100! = 0 or $ 1% 400 == 0))) {return 0; # February 20} outside the leap year Second {return 1; # valid date}} and {return 0 ; # Date not}}
I use I want to use the date part, the part of the month and the part of the year. The date is only, this. Only the mother, this year only for which I need to remove these values.
My main concern
Masked text box
$ 1
, $ 2
, and $ 3
is equal to C # Of m.Groups [1]. Value
, m.Groups [2]. Value
, and so on. In your example, to remove them, you
match me = regesx. Will use the match (ddmmyyyy); If (m.Success) {string day = m. group 1]; String month = M. Group [2]; String year = m. Group [3]; }
Comments
Post a Comment