Computing.Net > Forums > Programming > regex to convert csv to tab

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to get for your free account now!

regex to convert csv to tab

Reply to Message Icon

Name: mnlynam
Date: January 6, 2009 at 21:44:47 Pacific
OS: Microsoft Windows XP Professional
CPU/Ram: 1.894 GHz / 1406 MB
Manufacturer/Model: Hewlett-packard / Hp pavilion tx1000 notebook pc
Subcategory: Theory
Comment:

I am trying to find a regex pattern to replace semicolons with tabs if they are not within quotation marks, and remove quotes from fields that are not numbers only.


Report Offensive Message For Removal

Sponsored Link
Ads by Google

Response Number 1
Name: FishMonger
Date: January 7, 2009 at 05:57:11 Pacific
Reply:

A single regex won't be enough.

What language are you using?
What have you tried?


Report Offensive Follow Up For Removal

Response Number 2
Name: mnlynam
Date: January 7, 2009 at 16:03:18 Pacific
Reply:

I like the C# regex. Let's go with that. I have the first part:

C# = ";(?=([^\"]*\"*)*$|[^\"]*$)"

Javascript = /;(?=([^"]*"*)*$|[^"]*$)/im

Perl/Python = ';(?=([^"]*"*)*$|[^"]*$)'

Basic = ";(?=([^""]*""*)*$|[^""]*$)"


Report Offensive Follow Up For Removal

Response Number 3
Name: FishMonger
Date: January 7, 2009 at 20:51:01 Pacific
Reply:

When I asked "What have you tried?", I was expecting a more complete sample than less than 1/2 of a regex that is only required to match nothing more than a single semi-colon.

When you say that you "like the C# regex", does that mean that you plan on using C# to write the solution?

To meet your requirements, you''ll need more than a single regex, you may need a full csv parser.

My language of choice is Perl, and if you want to go that route, you may want to begin by looking over some of the CSV modules on CPAN.

http://search.cpan.org/search?query...
http://search.cpan.org/search?query...

However, if you plan on using C#, as I suspect, I'll bow out and let someone else help you since I don't know C#.


Report Offensive Follow Up For Removal
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: regex to convert csv to tab

Convert .asm to .c www.computing.net/answers/programming/convert-asm-to-c/7883.html

c++ code convert .bmp to .JPEG file www.computing.net/answers/programming/c-code-convert-bmp-to-jpeg-file/4383.html

converting text to binary www.computing.net/answers/programming/converting-text-to-binary/4891.html