RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find CSV Parser
Expression
((?:[^",]|(?:"(?:\\{2}|\\"|[^"])*?"))*)
Description
Very simple (but very useful!) regex to split CSV files. It does not drop the commas - you have to do that manually. Quotes are dealt with properly and escaped quotes are ignored. Matches from sample:this is ;a;"line,\"in\"a";csv;file
Matches
this is ,a,"line,\"in\",a",csv,file
Non-Matches
"
Author Rating: The rating for this expression. Alex Forencich
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Not CSV
Name: Andy
Date: 4/24/2007 7:30:24 AM
Comment:
This is a uesful format to split, however it is not CSV. CSV doubles the quotes to escape them (check wikipedia).


Title: Worked for me in C#, but I had to escape the embedded double quotes
Name: Rovert Prohaska
Date: 3/27/2007 4:34:00 PM
Comment:
Worked for me in C#, but I had to escape the embedded double quotes. Nice job. Thanks.


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials