Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
基本上我使用 bash shell 脚本来cat new | sed '/1. /,/<div/!d' > new2提取从. 然后将其保存到一个 new2 文件中。如何使用 pcre 在 php 中做同样的工作。 1. <div
cat new | sed '/1. /,/<div/!d' > new2
1. 
<div
$text = file_get_contents('php://stdin'); $matches = array(); if(preg_match('/1\. (.*?)<div/', $text, $matches)) { echo $matches[1]; }
测试:
echo 'abc 1. This is a test<div>more stuff<div>and more' | php test.php ;This is a test