Here's an adaptation of davorg's code to handle the multiline search.
The above is intended as Perl-ish pseudocode to give you an idea of what to do. The devil is in the details, in particular, in $regex_to_search_for. E.g. I added the /s attribute in case it included a "."; it may need additional or different attributes, but you probably want to keep the /g.open SEARCH, $file_to_search or die $!; my $text = do { local $/; <SEARCH> }; close SEARCH; my $count = 1; while ( $text =~ /($regex_to_search_for)/sg ) { open FOUND, '>', "found$count.txt" or die $!; print FOUND $1; ++$count; }
the lowliest monk
In reply to Re: Search a text and output to different text files
by tlm
in thread Search a text and output to different text files
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |