Extract lines matching pattern list - sort output

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

evilowl
Posts: 5
Joined: Thu Apr 12, 2012 11:10 pm

Extract lines matching pattern list - sort output

Postby evilowl » Fri Dec 30, 2016 10:24 pm

Good day.

Whether it's possible putting extracted lines in output file in the same order in which they were found?

Here is an example:

Extract lines matching perl pattern/using this text:

41401
41484
41486
41556

Output looks like this:

/done/DiB-41486 Auto Repair & ServiceBrake Repair.xls
/done/FM-41401 Locate Dealer Get A Quick Quote Estimate Payments.xls
/done/TS-41484 Home Improvements.xls
/done/TS-41556 Building Materials.xls

I need this:

/done/FM-41401 Locate Dealer Get A Quick Quote Estimate Payments.xls
/done/TS-41484 Home Improvements.xls
/done/DiB-41486 Auto Repair & ServiceBrake Repair.xls
/done/TS-41556 Building Materials.xls

i'm trying to sort output, but couldn't, because sought-for parameter of sort (5 digits) placed in lines haphazardly

Please help.

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

Re: Extract lines matching pattern list - sort output

Postby DataMystic Support » Fri Jan 06, 2017 7:28 am

Just match the EasyPattern

/done/[ capture(1+letters) as 'code', '-', capture(5 digits) as 'digits', longest 1+ not cr or lf) ]

Replace with

@digits@,$0

Then you can sort based on the first 5 digits of the line, then remove this column later on.
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

evilowl
Posts: 5
Joined: Thu Apr 12, 2012 11:10 pm

Re: Extract lines matching pattern list - sort output

Postby evilowl » Mon Jan 09, 2017 3:55 pm

Thank you very much.


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

Who is online

Users browsing this forum: Google [Bot] and 2 guests