...

View Full Version : Regex parsing



mathewvp
11-21-2003, 03:46 AM
I have a text database file which has entries like

//--First Record

|:010 Keyword1:itsvalue
:020 Keyword2:anothervalue
:030 Keyword3:thirdvalue
.......
......
....
:500 Keyword500:somevalue

//Second Record
|:0610 Keyword1:value
......
Records are separated by the "|" symbol(OR)

How do I parse it so that I can separate each record and take the keyword's values

Keywords and values are like "LOCATION:someplace","EMPLOYEE:contract" etc.
Each line starts with a :linenumber and also the data will have : like for website address (http://)


Can anybody help please?

firepages
11-21-2003, 06:57 PM
ouch thats a nasty format , are you stuck with it ? , perhaps better to change the storage format if possible or is that not an option ?

its parsable but avoiding regex is always optimal... how big are the individual files ?

mathewvp
11-22-2003, 03:44 AM
Changing the format is not an option coz the file is supplied by somebody else and I have to work on the file.Each record consists of around 100 fields and the total file db size around 15mb

missing-score
11-22-2003, 10:11 AM
:eek:

While it would be possible, it could take a long long time to work with 15 megs of text. Reading the file would take a while, then you would have to split it. While it's possible its highly unpractical. unless you only need to do it once?

mathewvp
11-24-2003, 03:47 AM
I have already split each record to individual files.I was looking for some code to teach me how to parse through the records.Thanks for the suggestions



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum