in reply to Re^4: Matching range of text with another string in between
in thread Matching range of text with another string in between
I downloaded "Free Hex Editor Neo" and I saw that the lines seem to end (or start?) with two dots ".." whose hex values are "0d 0a". These are not visible when the file is opened normally. I don't know if this helps.
Here is two full lines of actual text from the file which denotes the end of one section and the beginning of the next. It was probably unnecessary but I replaced the dollar figures with nines:
CAS*CO*999*999.99~ LX*2~
A line with the "00003" string.:
SVC*HC:00003*999.99*999.9**1~
At the moment I have the following code in a file named test_script.pl, which gets me the first 14 lines and the regex one-liner match gets me the last three:
use warnings; use strict; #Note that this script throws errors when pull file paths are defined. #Must be run from the path that the input/output files exist. open my $fhi, '<', 'cr835.txt' or die "$!"; open my $fho, '>', 'cr_output.txt' or die "$!"; #Prints the first 14 lines to the output file while(<$fhi>) { 1 .. 14 ? print : last; } close $fhi; close $fho; system( q(perl -nle "print if /SE\Q*\E3841/ .. /IEA\Q*\E/" "cr835.txt" +) );
I hope that the difficulty we have had wasn't caused by my leaving something important out of my initial post.
|
|---|