counting commas
Posted: Tue Dec 11, 2001 5:03 pm
I've got a text file that's almost considered free-form. What I need to do, in a particular section that is comma seperated, I need to be sure there are 7 commas to the line (or 8 fields, where the 8th field is mostly blank), no more and no less. Those not having 7 commas (or more than 7) need to be marked for fixing.
I've had information overload on regular expressions trying to figure out how to flag these lines. The section might look like the samples below or any combination that can be derived....there's no consistency to what's in these fields except there has to be 8.
field1,field2,,field4, field5, field6, field7,field8
field1,,,,,,,
field1, field2,,,,,,field8
field1,field2,, field4, field5, field6, field7, field8, field1, field2, field3...
I appreciate any help...Thanks.
I've had information overload on regular expressions trying to figure out how to flag these lines. The section might look like the samples below or any combination that can be derived....there's no consistency to what's in these fields except there has to be 8.
field1,field2,,field4, field5, field6, field7,field8
field1,,,,,,,
field1, field2,,,,,,field8
field1,field2,, field4, field5, field6, field7, field8, field1, field2, field3...
I appreciate any help...Thanks.