Page 1 of 1

Find subject, extract X characters before and Y characters after

Posted: Mon Nov 02, 2015 9:06 am
by apportum
I want to search a 200+ GB file for specific targets (i.e., "jsmith@zmail.com").

When a target is found, I want to extract X characters before the target and Y characters after.

Thus the results might look something like ("abcd" . . . [80 characters] . . . jsmith@zmail.com . . . [750 characters] . . . "wxyz").

Is this possible in TextPipe v9.9.

Jerry

Re: Find subject, extract X characters before and Y characters after

Posted: Wed Nov 04, 2015 8:30 am
by DataMystic Support
Hi Jerry,

Yes, absolutely. The simplest way to do this is with an EasyPattern search/replace:

Code: Select all

[40 characters]jsmith@zmail.com[40 characters]
Replace with:

Code: Select all

$0\r\n
And turn extract matches on - this discards non-matching text.

This outputs each match on a line of its own.

Do you need to know the line number? If so, an Extract Matches filter can be better, as it includes the line number and can also include lines of context before and after.