Christopher Glaeser wrote:
I want to extract several lines from an html file that begin with pattern1
and end with pattern2 and ignore everything before pattern1 and after
pattern2. Any snippets or suggestions will be greatly appreciated.
preg_match_all() is your friend
http://www.php.net/preg_match_all
example:
<?php
$data = 'p1p2p3p4p5p6p5p4p3p2p1p2p3p4p5p6';
$pat1 = 'p2';
$pat2 = 'p5';
preg_match_all("@$pat1(.*)$pat2@Uim", $data, $matches);
echo '<pre>'; print_r($matches); echo '</pre>';
?>
NOTE: script typed directly and NOT tested.
PS: I found another use for double quotes :)
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--