in reply to Regex latest match?
You can use the following piece of code.
#!/usr/bin/perl -w use strict; my $filename = 'regex_data.txt'; open INPUTFILE , $filename or die "Cannot Open : $filename : $!"; while ( <INPUTFILE> ) { chomp $_; print "$2\n" if ( $_ =~ /^.*(start\:)(.*)(stop\:)/gi ) } close INPUTFILE;
Assume that the file "regex_data.txt" contains your data. This code will print only the data between the last "start:" - "stop:" pair.
Hope this will help you !
|
|---|