I have a CSV that uses ,(comma) as the delimiter. This CSV is nearly 20K lines long and there are 10 instances where a comma was used INSIDE the data. These errant commas are breaking my processor.In VIM, how would you locate ONLY the lines that have more than 1 comma?I can find all commas using :%s/,//gnThis tells me I have 17655 commas on 17646 lines. There should only be 17646 commas, 1 per line, in the entire file. What is an easy way to locate any line with more than one comma on it?
How to find multiple instances of same character on single line?
search;regular expression
I can think of two expressions offhand that may work for you. They both worked on some quick, limited test data I tried. The first expression is\(.\{-},\)\{2,}This translates to match at least 2 sequences of (as few as possible of anything followed by a comma). In other words this tries to find matches of two or more sequences of comma-delimited text ranges.Another is.\{-},\@<=.*,Which is find anything followed by a comma, but only if immediately prior to that you could find as few as possible of anything followed by a comma.I'm not sure if one or the other is more preferable. I find the first one easier to reason about, even though I came up with the second, more complex one first. You may need to anchor them with ^ to the start of the line.Karl Yngve Lervg's answer has an even simpler regex that works just as well as my overengineered options.With them, you can use the global command (:help global) to operate on the matching lines with some Ex command: :g/.\{-},\@<=.*,/d for example, will delete all the lines with more than one comma in them.