GREP for Duplicate Lines (and then replacing it)
Dear Community,
I think this is probably a job that GREP can take care of very quickly if I could just get help with the code to do it.
I have been attempting to at least figure out what GREP I need to just find the words, but I'm failing miserably, and I know there a bunch of experts on here. (?<=\t )(.+)\1 was my last attempt before I decided that trying to figure this out for an hour is ridiculous when someone on here will just simply know how to do it. I'm at the tail end of this 2 month long project with the deadline approaching quickly (Dec 3).
Possible Solution?
My thought is that there must be a GREP which could find a duplication of the words (the book title) perhaps with use of that constant factor of the tab on every line, then replace the duplicate word with: remove paragraph break, remove tab, add a comma. This would have the effect of bumping up the number on the duplicate line to the line above it, with the numbers being listed in increasing order and separated by commas. I just don't know how to write the GREP itself. The more I've thought about it and come up with that logic the more convinced I am that GREP can do it.
Example of Problem (words underlined are invisible characters):
199 Animals tab 6 paragraph break
199 Animals tab 24 paragraph break
199 Animals tab 178 paragraph break
Big Book of non-breaking space Dinosaurs tab 13 paragraph break
Big Book of non-breaking space Dinosaurs tab 59 paragraph break
Big Book of non-breaking space Dinosaurs tab 211 paragraph break
Bugs (Little Lift and Look) tab 9 paragraph break
Bugs (Little Lift and Look) tab 105 paragraph break
I need a GREP which will make these turn into:
199 Animals 6, 24, 178
Big Book of Dinosaurs 13, 59, 211
Bugs (Little Lift and Look) 9, 105
Thank you very much for taking the time to read my plea for help,
Rachael
