Re: Regex question
- From: "Josh Einstein" <josheinstein@xxxxxxxxxxx>
- Date: Tue, 30 Dec 2008 09:57:59 -0500
I didn't say that finding date patterns was a lousy use of Regex. I said that trying to write such a complex Regex that it ensured it only matched valid dates (ie. did not match 99/99/9999) would be a lousy use. A blend of the two approaches is best - use Regex to get something that "looks" like a date and use DateTime to ensure it is valid.
You see this type of thing all the time when you see people write IP address or Email Address regex's. They go crazy trying to make it RFC compliant or ensure that it won't match anything invalid. But the regex quickly becomes unreadable and actually much slower than parsing.
So in summary - a simple regex gets you most of the way there and a parse confirms the validity. Sounds like you've got it working the way you want.
Good luck! Merry Christmas and Happy New Year!
Josh Einstein
"tshad" <tfs@xxxxxxxxxxxxxx> wrote in message news:u6lieXeaJHA.880@xxxxxxxxxxxxxxxxxxxxxxx
Regex will help you get most of the way there but trying to construct a pattern that will ensure a valid date within the range allowed by T-SQL would be a really lousy use of Regex in the first place.I know know why it is a lousy use of it. Seems like a better way to find a date pattern in my text field then trying to parse the field with for/loops to find a date.
Thanks,
.
- Follow-Ups:
- Re: Regex question
- From: tshad
- Re: Regex question
- References:
- Regex question
- From: tshad
- Re: Regex question
- From: Jeff Johnson
- Re: Regex question
- From: tshad
- Re: Regex question
- From: Josh Einstein
- Re: Regex question
- From: tshad
- Regex question
- Prev by Date: MVC fundamental website question
- Next by Date: Re: How to popup a ToolTip from code?
- Previous by thread: Re: Regex question
- Next by thread: Re: Regex question
- Index(es):
Relevant Pages
|