Re: best design for parse
- From: "Cor Ligthert [MVP]" <notmyfirstname@xxxxxxxxx>
- Date: Mon, 8 Jan 2007 06:44:14 +0100
GS,
As long as you don't know the date format, you can probably do nothing.
As soon as you know the dateformat, you can try to use the
DateTime.ParseExact with the given patern.
(Don't forget to set the mm in Upercase and let it not be done by the user).
Cor
"GS" <gsmsnews.microsoft.comGS@xxxxxxxxxxxxxxxxx> schreef in bericht
news:eFm$y5rMHHA.4376@xxxxxxxxxxxxxxxxxxxxxxx
You are sort of on the same track as mine.
I must first apologize I did not tell you the complete story.
Although the application does not exactly know before hand what format the
data may come in, however part of the application allow user to define and
record favourite for a website
- to extract by text or html
- header content and format
- record format and date format ( that is where the date format mask
come in)
- optionally ordinal number for each column or re-ordering
- trailer content and format
For a given batch, at least for the body, date format are uniform
furthermore, the need to make the extract process generic and adaptable to
the front end that takes the user definitions, I believe it would be
easier
to "normalize" date string to "yyyy-mm-dd".
Also the end target for of may not necessarily be SQL database but may be
text, pasted to word report. or excel by user
Therefore, I can transform the date format mask to regex in the
appropriate
format and identifier I can use regex,replace to normalize the date. As a
matter of fact the date separator does not have to / but can be space as
long as there are identifiable delimiter around the date string.
I already have code for dealing with regex for dates from prior project.
all I have to do is adapt to the present need
who knows, maybe I taken on a totally offbeat tract
"GS" <gsmsnews.microsoft.comGS@xxxxxxxxxxxxxxxxx> wrote in message
news:%23vnOBJiMHHA.1280@xxxxxxxxxxxxxxxxxxxxxxx
thanks for all pitched in so far.2:
let give it another shot.
looks like an easier way out would be
1.copy the date format string regex string holder and then derive the
relevant regex expression to be used for date normalization later in part
replace the regex string the yyyy to regex year expression with yearmonth
identifier
look for yy and replace with 20yy and repeat the step above
replace mmm with the month regex expression associated with month
identifier
replace mm with the 2 digit month regex expression associated with
identifierformat
replace dd with the 2 digit day regix expression assoc. with day
identifier
2. use the resulting regex in regex replace to normalize to yyyy--mm-dd
any problem with the above approach?
"Cor Ligthert [MVP]" <notmyfirstname@xxxxxxxxx> wrote in message
news:%23Qj7TbWMHHA.3944@xxxxxxxxxxxxxxxxxxxxxxx
GS,
Maybe can you avoid this in 2007 and all things like that as
DateTime.parseExact, but have a look to the nicely by Microsoft inbuild
globalization and than the to that related ToString option.
Cor
"gs" <gs@xxxxxxxxxxxxxx> schreef in bericht
news:OtrnsPTMHHA.4720@xxxxxxxxxxxxxxxxxxxxxxx
let say I have to deal with various date format and I am give format
string from one of the following
dd/mm/yyyy
mm/dd/yyyy
dd/mmm/yyyy
mmm/dd/yyyy
dd/mm/yy
mm/dd/yy
dd/mmm/yy
mmm/dd/yy
dd/mm
what is the best way to come up a relevant regex for the incoming
string
a) use two array and statically match
b) use regex to find the order
.
- References:
- best design for parse
- From: gs
- Re: best design for parse
- From: Cor Ligthert [MVP]
- Re: best design for parse
- From: GS
- Re: best design for parse
- From: GS
- best design for parse
- Prev by Date: RE: Hidden Process
- Next by Date: Re: connectivity to Oracle
- Previous by thread: Re: best design for parse
- Next by thread: Re: best design for parse
- Index(es):
Relevant Pages
|