basically I am using bash shell script cat new | sed '/1. /,/<div/!d' > new2 to extract text starting from 1.  and ending at first occurrence of <div. And then saving it into a new2 file. How to do the same work in php using pcre.  
            Asked
            
        
        
            Active
            
        
            Viewed 291 times
        
    1 Answers
1
            $text = file_get_contents('php://stdin');
$matches = array();
if(preg_match('/1\. (.*?)<div/', $text, $matches)) {
  echo $matches[1];
}
Test:
echo 'abc 1. This is a test<div>more stuff<div>and more' | php test.php
;This is a test
 
    
    
        Gary G
        
- 5,692
- 2
- 27
- 18
