Find subject, extract X characters before and Y characters after

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

apportum
Posts: 9
Joined: Thu Aug 20, 2009 5:00 pm

Find subject, extract X characters before and Y characters after

Postby apportum » Mon Nov 02, 2015 9:06 am

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

User avatar
DataMystic Support
Site Admin
Posts: 2154
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

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

Postby DataMystic Support » Wed Nov 04, 2015 8:30 am

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.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: No registered users and 1 guest