Regular expression help

Posted by DJPB on Stack Overflow See other posts from Stack Overflow or by DJPB
Published on 2010-04-28T14:56:55Z Indexed on 2010/04/28 16:43 UTC
Read the original article Hit count: 467

Filed under:
|
|

I there I'm working on a C# app, and I get a string with a date or part of a date and i need to take day, month and year for that string

ex: 
string example='31-12-2010'
string day = Regex.Match(example, "REGULAR EXPRESSION FOR DAY").ToString();
string month = Regex.Match(example, "REGULAR EXPRESSION FOR MONTH").ToString()
string year = Regex.Match(example, "REGULAR EXPRESSION FOR YEAR").ToString()

day = "31"
month = "12"
year = "2010"

ex2: 
string example='12-2010'

string month = Regex.Match(example, "REGULAR EXPRESSION FOR MONTH").ToString()
string year = Regex.Match(example, "REGULAR EXPRESSION FOR YEAR").ToString()

month = "12"
year = "2010"

any idea? tks

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex