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

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details Parsing VB Strings (or csv qualified strings)
Expression
((?:(?:"[^"]*")|('[^\r]*)(\r\n)?)*)([\s]*[,]|$) {CHANGED TO) (?<![\"\w\d\s])[\s]*(?:"((?:[^\"]|[\"]{2})*)"|([\w\d\s]+))[\s]*(?=[\,]|[\r\n]+|$)
Description
I started out looking for a way to propertly parse delimited CSV text. Everything that I tried on my own was not doing what I wanted it to do, so I borrowed one from someone here and customized it a bit to get pretty close to what I wanted (see ORIGIONAL MESSAGE below). Ultimately though, I still needed more functionality, so I started over, and came up with this. It actually does a very good job of actually parsing columns from the CSV text. I use Regex Replace( csvText, "[$1$2]" ) to actually see the column content, but there are many other ways (obviously). ORIGIONAL MESSAGE: ____________________________________________________ I was having trouble parsing fields from csv files due to the string qualifiers, when I came across a regex posted by Tom Svensson. It didn't quite meet my needs though because it was parsing the substrings (escaped quotes) as seperate results. This one will actually parse the entire string out, with it's escaped quote portion. None the less, thank you Tom Svensson for your help!
Matches
"a""b""c", "d""e""f", JHI, 234 (pulls: a""b""c and d""e""f and JHI 234)
Non-Matches
asd"
Author Rating: Not yet rated. David Oldfield
   Displaying page 1 of 1 pages; Items 1 to 1

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