in reply to Take last instance of a string
You haven't shown any of your preexisting code, so I'll just assume that the whole document is in a single scalar already. Then you can simply a regular expression:
my $string = <<STATEMENT; Wal-mart talks about its Significant Accounting Policies in its 10k. Significant Accounting Policies are important for a firm. Here is a list of the Significant Accounting Policies </b> 1)Lifo 2)Depreciation 3)Expenses STATEMENT if( $string =~ m/(.*)Significant\s+Accounting\s+Policies\b(.*)$/m ) { print "Found stuff: $2\n"; } else { print "Match failed\n"; };
This relies on the first .* group being greedy and gobbling up as much as possible from the string, thus leaving only the last Significant Accounting Policies instance for the match.
|
|---|