regex to convert csv to tab

Hewlett-packard / Hp pavilion tx1000 notebo...
January 6, 2009 at 21:44:47
Specs: Microsoft Windows XP Professional, 1.894 GHz / 1406 MB
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.

See More: regex to convert csv to tab

Report •

January 7, 2009 at 05:57:11
A single regex won't be enough.

What language are you using?
What have you tried?

Report •

January 7, 2009 at 16:03:18
I like the C# regex. Let's go with that. I have the first part:

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

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

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

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

Report •

January 7, 2009 at 20:51:01
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.

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 •

Related Solutions

Ask Question