I'm struggling with a Grep Find/Replace action to apply to a file with sorted lines, each having three units separated by tabs:

first1 second11    third111
first1 second11    third112
first1 second11    third113
first1 second11    third114
first1 second11    third115
first2 second21    third211
first2 second22    third221
first2 second23    third231
first3 second31    third311
first3 second31    third312
first3 second31    third313
first3 second31    third314
first3 second32    third321
first4 second41    third411
first4 second41    third412
first4 second42    third421
first4 second42    third422
first5 second51    third511
first5 second52    third521
first5 second52    third522
first5 second52    third523
first5 second53    third531
...


Now I need to insert an underscore at the beginning of each line IF the "first" and "second" fields are identical to the respective fields in its previous line. The result should be this:

first1 second11    third111
_first1 second11    third112
_first1 second11    third113
_first1 second11    third114
_first1 second11    third115
first2 second21    third211
first2 second22    third221
first2 second23    third231
first3 second31    third311
_first3 second31    third312
_first3 second31    third313
_first3 second31    third314
first3 second32    third321
first4 second41    third411
_first4 second41    third412
first4 second42    third421
_first4 second42    third422
first5 second51    third511
first5 second52    third521
_first5 second52    third522
_first5 second52    third523
first5 second53    third531
...

I presume this could be achieved by using positive look-behind assertion, but all my attempts have failed so far.

Any help greatly is appreciated!

samar

--
This is the BBEdit Talk public discussion group. If you have a feature request or need 
technical support, please email "[email protected]" rather than posting here. 
Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/0596413f-15bb-62f9-6cb7-47ad2bab4e08%40bluewin.ch.

Reply via email to