Page 1 of 1

Extract lines matching pattern list - sort output

Posted: Fri Dec 30, 2016 10:24 pm
by evilowl
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.

Re: Extract lines matching pattern list - sort output

Posted: Fri Jan 06, 2017 7:28 am
by DataMystic Support
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.

Re: Extract lines matching pattern list - sort output

Posted: Mon Jan 09, 2017 3:55 pm
by evilowl
Thank you very much.