Yes, another question in Regex. Welcome; -P
This is the first time I have written my own regex for some simple string checking in C #. I think it works for me, but as a training exercise, I was wondering if it was possible to improve it and if I made any mistakes.
The lines will look something like this:
T20160307.0001
Rules:
- Start with the letter T.
- Date in YYYYMMDD format.
- Full stop.
- The last 4 characters are always numeric. Must be exactly 4.
Here is my regex ( fiddle ):
^ (? I) [T] 20 [0-9] {2} [0-1] [0-9] [0-3] [0-9]. \ D {4} $ p>
^ Approve the beginning of the line.(?i)[T] Make sure we have a case insensitive letter T.20 20 ( 2100 , : -P)[0-9]{2} 0 99 YYYY.[0-1][0-9] 0 1 , 0-9 .[0-3][0-9] 0-3 , 0-9 .. .\d{4} 4 .$ .
, , - . 20161935 (35- 19- ) . // , , , , .
, , - ELI5, , .
: , , DateTime.TryParse .. , Regex , . , , .