c# - How to get a proper date from a text? -
i have find date text file text should int form of dd mm or mm dd (i.e. 1. 10 january or 2. january 10) have written type of regex (\d{2} january)
.it gives 10 january want write
1. single regex can both date format (i have option can write same (\d{2} january)|(january \d{2})
.)
2. valid date number (i.e. regex returns true if have 99 january in text invalid). cases should match
- 1 january
- 02 january
- 29 january
- 32 january
- 2004 january
- january 2004
- january 32
- january 29
- january 1
- january 01
those in bold case should valid match , other invalid.
this pattern needs month names once:
\b((?<day>[0-2]?\d|3[01]) )?january(?(day)| ([0-2]?\d|3[01]))\b
but matches days 0 31. day patterns are:
- 0-31: [0-2]?\d|3[01]
- 0-30: [0-2]?\d|30
- 0-29: [0-2]?\d
- 0-28: [01]?\d|2[0-8]
Comments
Post a Comment