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.
counting commas
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
Mark Schnitzius
Re: counting commas
Do a search (with regular expression turned on) for
^[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*\n
and select \"Mark All\". The unmarked lines will be the ones you're interested in.
^[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*\n
and select \"Mark All\". The unmarked lines will be the ones you're interested in.
-
Ed Orchard
Re: counting commas
The final \n should be replaced with $ (or \n which is less efficient).
menu search/invert all bookmarks will then bookmark all lines needing attention
menu search/invert all bookmarks will then bookmark all lines needing attention