Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.
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
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
![]() |
![]() |
![]() |

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