Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2007

Tip: Looking for answers? Try searching our database.

Parsing Text using RegExp

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Barry - 23 Jun 2007 15:12 GMT
Hi

Sometime ago i had posted a request for code to parse a line of text
containing Quotes and Commas, the code posted by the gentleman did work for
sometime but does not work for the following

104528558,"New iPod FM Transmitter & Car Charger
$1Res(E107)","/Electronics-photography/Portable-audio-iPods/iPod-accessories/FM-Transmitters-iTrips","Jun
21 2007 12:28PM","Fixed price offer",29,"$6 Courier Nationwide (Rural +3)
No pick-ups allowed","$6.00 Courier Nationwide (Rural
+3)","kjc",,,"kyliec@astra.co.nz",0,3.25,1.71,,1,1,39.95,"Jun 13 2007
9:00PM","7 days",,"yes","yes","yes","no","no","no",5,,"no"

the following is the code that does not work for the above
Regex regex = new
    Regex("((?<field>[^\",\\r\\n]+)|\"(?<field>([^\"]|\"\")+)\")(,|(?<rowbreak>\\r\\n|\\n|$))");

Can someone help

Barry
Göran Andersson - 24 Jun 2007 13:53 GMT
> Sometime ago i had posted a request for code to parse a line of text
> containing Quotes and Commas, the code posted by the gentleman did work for
[quoted text clipped - 12 lines]
>
> Can someone help

What exactly do you mean by "does not work"?

I tried it, and it works just fine.

Signature

Göran Andersson
_____
http://www.guffa.com

Barry - 25 Jun 2007 08:56 GMT
Yes, it does work, my question was slightly incorrect.

It works but return ONLY 26 of the 30 expected fields, whenever there are

"124",,,"152"
it will show return only 2 fileds not 4 for the above line

You can try to create a csv file with my line of text and open a excel sheet
for testing.

Correct me if i am wrong.

>> Sometime ago i had posted a request for code to parse a line of text
>> containing Quotes and Commas, the code posted by the gentleman did work
[quoted text clipped - 17 lines]
>
> I tried it, and it works just fine.
Göran Andersson - 25 Jun 2007 18:01 GMT
> Yes, it does work, my question was slightly incorrect.
>
[quoted text clipped - 28 lines]
>>
>> I tried it, and it works just fine.

Yes, the pattern does not include empty items.

To make it include empty non-quoted items, change the first + to *.

To make it include empty quoted items, change the second + to *.

Signature

Göran Andersson
_____
http://www.guffa.com

1store - 25 Jun 2007 04:37 GMT
What type of website are your trying to make?
Barry - 25 Jun 2007 08:58 GMT
does it matter, for all you know i may not be trying to make a website at
all, i could be using it for a different purpose, that is immaterial for the
posting

> What type of website are your trying to make?
1store - 25 Jun 2007 04:38 GMT
What type of website are your trying to make?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.