Re: Regex question
- From: "tshad" <tfs@xxxxxxxxxxxxxx>
- Date: Thu, 25 Dec 2008 14:16:57 -0800
"Arne Vajhøj" <arne@xxxxxxxxxx> wrote in message
news:494d099a$0$90276$14726298@xxxxxxxxxxxxxxxxxx
tshad wrote:
"Arne Vajhøj" <arne@xxxxxxxxxx> wrote in message
news:494c4fb2$0$90274$14726298@xxxxxxxxxxxxxxxxxx
tshad wrote:
This is really a regex question.For inspiration see below.
I am wonding if anyone knows a good Regex expression that would pull a
valid date from a string.
I have used:
strValue = Regex.Replace(valueIn, @"[^\d/]", "");
which works most of the time.
But I have some cases where I have strings like:
05/07/08(-4%)
09/19/08 DOM 55
09/19/2008 DOM 53
FOR 09/15/08 -23
That looks good. Would that handle 1 and 2 digits for days and months
and 2 and 4 for years?
private static readonly Regex re = new
Regex(@"\d{2}/\d{2}/\d{2}", RegexOptions.Compiled);
@"\d{1,2}/\d{1,2}/\d{2,4}"
is more flexible.
Great. That really helps.
Thanks,
Tom
Arne
.
- References:
- Regex question
- From: tshad
- Re: Regex question
- From: Arne Vajhøj
- Re: Regex question
- From: tshad
- Re: Regex question
- From: Arne Vajhøj
- Regex question
- Prev by Date: docx merge lib
- Next by Date: Re: Regex question
- Previous by thread: Re: Regex question
- Next by thread: Re: Regex question
- Index(es):
Relevant Pages
|
Loading