grep: removing a column in a tab-delimited file

374 views
Skip to first unread message

ChuckSoper

unread,
Mar 13, 2009, 5:50:57 PM3/13/09
to BBEdit Talk
Hello,

I'm trying to delete the fourth column of a tab-delimited text file. I
think that this is relatively straightforward. Excel failed at this
task because it changed my date formats automatically. I'm also not
confident that it preserves the text encoding.

I just accidentally sent a partially written email to the list. In the
meantime, I discovered the answer to my issue. I re-read the help
section on Matching Delimited Strings. I believe that I need to use a
grep pattern that specifies any character except a tab then repeat it.
I'm trying to find the first four columns and replace with the first
three columns. Something like this:

Search for: (^(.+?\t){3})((.+?\t){1})
Replace: \1

This works great! I love BBEdit.

Thanks,
Chuck

Lewis@Gmail

unread,
Mar 14, 2009, 7:30:52 PM3/14/09
to bbe...@googlegroups.com
On 13-Mar-2009, at 15:50, ChuckSoper wrote:
> I'm trying to delete the fourth column of a tab-delimited text file. I
> think that this is relatively straightforward. Excel failed at this
> task because it changed my date formats automatically. I'm also not
> confident that it preserves the text encoding.

I use option-click+drag for this.

> Search for: (^(.+?\t){3})((.+?\t){1})
> Replace: \1

Yep, that works too.

> This works great! I love BBEdit.

Well, in this specific case it is PCREs you love :)


--
I'm no psychologist (although I play one when I'm picking up chicks
over by the asylum)

Reply all
Reply to author
Forward
0 new messages