in reply to finding commas within commas
Outputs: ["2","TESTB","Lazowsky","Mike's","Teststring"]#!/usr/local/bin/perl -w use strict; my $string = q{"2","T,E,S,T,B","Lazowsky","Mike's","Teststring"}; $string =~ s/,(?!")//g; print qq{[$string]\n};
Uses Negative Lookahead Assertion.
Essentially, this is saying, to remove any commas, as long as they are not followed by a double quote.
Warning: definitely not production code, there are several problems with this.
Text::CSV,
is the way to go.
Best Regards,
Wonko
|
|---|