Displaying page
of
pages;
Items to
Title |
Test
Details
Pattern Title
|
Expression |
(?<=(?:^|,)")(?:[^"]|"")+ |
Description |
A regex that will split a CSV file when used for MATCH function.
All values must be in quotes, and seperated by commas.
Ex. "test1","test2","test3"
Quotes themselves are not captured
Note: Only works in regex engines that support backreferences (Java, .NET, php, etc). JavaScript is not one of them. |
Matches |
"test1","test2" |
Non-Matches |
test1,test2 |
Author |
Rating:
Andrew Stakhov
|
Title |
Test
Details
Pattern Title
|
Expression |
(?<=,)\s*(?=,)|^(?=,)|[^\"]{2,}(?=\")|([^,\"]+(?=,|$)) |
Description |
Use for parsing CSV files exported from MS Excel, This program adds or not quotes, so it's more complicated..
Use for parsing individual lines, the Regex doesn't capture end of line (supposed to ($) but not made it in the testing so you cannot parse the whole file.
Read a line and split it, with this regex
|
Matches |
,Casa en condominio / Traspaso,"$270,000 ","mn,","Toluca,","67 m2 |
Non-Matches |
"" |
Author |
Rating:
itzco calva
|
Title |
Test
Details
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:
Alex Forencich
|
Title |
Test
Details
Pattern Title
|
Expression |
((?<=,\s*\")([^\"]*|([^\"]*\"\"[^""]*\"\"[^\"]*)+)(?=\"\s*,))|((?<=,)[^,\"]*(?=,)) |
Description |
Parse CSV.
First You need add to begin and to end of every line comma. Example. You need to get line like ,test,"test1",..., "testN", .And after You can parse line. |
Matches |
John,Doe,120 jefferson st.,Riverside, NJ, 08075 Jack,McGinnis,220 hobo Av.,Phila, PA,09119 "J |
Non-Matches |
non |
Author |
Rating:
Not yet rated.
pavel smetanin
|
Title |
Test
Details
File Upload
|
Expression |
^(?<Drive>([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(?<Year>\d{4})-(?<Month>\d{1,2})-(?<Day>\d{1,2})(?<ExtraText>.*)(?<Extension>.csv|.CSV)$ |
Description |
Allows a file with the format <drive><directory>yyyy-mm-dd-DailyUpload.csv |
Matches |
c:\upload\yyyy-mm-dd-DailyUpload.csv |
Non-Matches |
DailyUpload.csv |
Author |
Rating:
Not yet rated.
Paul Griffin
|
Title |
Test
Details
CSV exported from Excel (all variants)
|
Expression |
;?(?:(?:"((?:[^"]|"")*)")|([^;]*)) |
Description |
This expressions parses one line from a CSV file which has been written with Excel. It does cover all variants: simple value, value masked by double quotes (including semicolons between double quotes which don't count) and double quotes masked by double quotes (""). Replace all semicolons within the regex to change the separator character. |
Matches |
abc;efg;"Column with ;";"Column with ; and ""double quotes""";;ijk; |
Non-Matches |
abc,efg,'test',ijk |
Author |
Rating:
Sven
|
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
|
Title |
Test
Details
Validate a 3 field CSV file
|
Expression |
^(([^,\n]+),([^,\n]+),([^@]+)@([^\.]+)\.([^,\n]+)\n)+([^,\n]+),([^,\n]+),([^@]+)@([^\.]+)\.([^,\n]+)\n?$ |
Description |
This pattern validates a 3 field CSV file. I designed it to capture first name, last name and email address in that order. |
Matches |
|
Non-Matches |
|
Author |
Rating:
Not yet rated.
Mark Newman
|
Title |
Test
Details
Match fields in a csv row
|
Expression |
(\"(?<word>[^\"]+|\"\")*\"|(?<word>[^,]*)) |
Description |
This will match fields in a row of a csv file. Values can be double quoted or not. If a value is double quoted it can have commas inside it. Each value will be captured to word. |
Matches |
"test","test this",test, test,test ,"123,456.12" |
Non-Matches |
'te, st' |
Author |
Rating:
jeremy chapman
|
Title |
Test
Details
List of digits, CSV
|
Expression |
^(\d{4},?)+$ |
Description |
Accepts a list of 4 digits separated by commas. Used to validate a list of years. Can be easily customized to change the number of digits. |
Matches |
2001,2002,2003 | 1999 | 1999,2000, |
Non-Matches |
123 | 1234,e,1234 | 1234, 1234,1234 |
Author |
Rating:
Luc Boudreau
|
Title |
Test
Details
CSV parser (with Quotes) (.NET)
|
Expression |
\A[^,"]*(?=,)|(?:[^",]*"[^"]*"[^",]*)+|[^",]*"[^"]*\Z|(?<=,)[^,]*(?=,)|(?<=,)[^,]*\Z|\A[^,]*\Z |
Description |
Returns the value from a CSV line. |
Matches |
,,"",a,a"",""a,a""a,aa""a,",",a"a,a"a",aa",bb" | as,"fsfdf,g | ,"as,"fsfdf,g" |
Non-Matches |
| |
Author |
Rating:
Iulian Fecioru
|
Title |
Test
Details
CSV - Numbers
|
Expression |
^[0-9]+(,[0-9]+)*$ |
Description |
Parses comma-separated numbers. Doesn't allow spaces inbetween numbers and/or between numbers and commas. Allows single number to be added. Doesn't allow sequence to end with a comma. |
Matches |
1321 | 1321,0,42412 | 0,1,2,3,4 |
Non-Matches |
1321,,42412 | 12c,13d,23 | 445, | 412 , 421, 4122 | 42 4,41 |
Author |
Rating:
Kristijan Prikratki
|
Title |
Test
Details
Absolute File Path in UNIX / LINUX
|
Expression |
^((?!.*//.*)(?!.*/ .*)/{1}([^\\(){}:\*\?<>\|\"\'])+\.(csv|jpg|txt|pdf|dat|xls|doc))$ |
Description |
This will match with all absolute file paths in Unix/Linux. The extensions added are csv|jpg|txt|pdf|dat|xls|doc. Can be customized for specific extensions. |
Matches |
/usr/local/data/userdata.xls, /home/userdata.doc, /accounts.txt |
Non-Matches |
//usr/local/data/userdata.xls, //usr/local/,/usr/local/ data/users.txt |
Author |
Rating:
Bijaya Kumar Naik
|
Title |
Test
Details
Extracting bible verses with Vim
|
Expression |
/(\d?\s?\w+),(\d+),(\d+),(/d*),/\1 \2:\3-\4/g |
Description |
I had a CSV file with following format: book,chapter,verse_start,verse_end,notes
I wanted to transform the rows to traditional english verse representations (i.e. "1 Timothy 2:2-4")
Unfortunately, this regex always puts a '-' after the verse_start, so if verse_end is empty, the translated version will have a trailing '-'.
Vim needs everything escaped, so here is the actual vim command for the substitution:
:%s/\(\d\?\s\?\w\+\),\(\d\+\),\(\d\+\),\(\d*\),/\1 \2:\3-\4/g |
Matches |
1 Timothy,2,2,4,|John,6,3,,|A,123,4,4, |
Non-Matches |
12 Timothy,2,2,4,|2 Timothy 2,2,4|A Corinthians 3,3,,|John,3,,,|John,3,,3, |
Author |
Rating:
Not yet rated.
Tyler Durkota
|
Displaying page
of
pages;
Items to