I'm looking for something which I assume is pretty easy to accomplish with GREP but I fail to see how.I have a large text file with entries sorted in this way:
...That is, the first element is replaced by a tab character *if* the first element is a repetition of the first element of the previous line(s). The sort order remains unchanged.
On Mar 20, 2021, at 4:30 AM, samar <arne...@bluewin.ch> wrote:
HiThis is the first time a post a message here.I'm looking for something which I assume is pretty easy to accomplish with GREP but I fail to see how.I have a large text file with entries sorted in this way:
<tab1.png>That is, each line has two elements (represented here by A\d and B\d) separated by one tab character. The length of the two elements is between 1 and 100 characters each.Now I need a GREP Find/Replace string to make it look like this:
<tab2.png>That is, the first element is replaced by a tab character *if* the first element is a repetition of the first element of the previous line(s). The sort order remains unchanged.Sounds simple. And yet all I manage to GREP for is this:
<Screenshot 2021-03-20 at 12.26.11.png>The result looks promising but in now way satisfactory:
<Screenshot 2021-03-20 at 12.22.46.png>The tab characters are inserted correctly, but the problem has to do with repetition ... Does anyone see how this can be resolved?Thankssamar
...when I run the text filter, not all occurrences of the first element get replaced when necessary:
<tab3.png>Here a tab should also replace A1 in line 5, A2 in line 12, and A3 in line 18.
That makes no sense to me. If the current col1 is identical to col1 of the previous line, then the value will not be printed; that is the clear logic of the routine. I cannot reproduce your error.
--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" 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 bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/B75B0684-484C-4034-AF69-D0731A9FE590%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/9531484b-8ac0-4e99-b63a-0662d5b5c654n%40googlegroups.com.
The reason you cannot reproduce the error with your file may be that the second column is limited to three different texts (B1, B2, and B3) whereas in mine there are more (up to B7 here, but the script should also work with more than seven):
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/1aaf8e41-f479-431e-a290-777609746a27n%40googlegroups.com.
The reason you cannot reproduce the error with your file may be that the second column is limited to three different texts (B1, B2, and B3) whereas in mine there are more (up to B7 here, but the script should also work with more than seven):
A1 B1A1 B2
A1 B3
A1 B4
A1 B5