正在显示
1 个修改的文件
包含
11 行增加
和
15 行删除
| @@ -158,21 +158,17 @@ class ProofreadingController extends BaseController | @@ -158,21 +158,17 @@ class ProofreadingController extends BaseController | ||
| 158 | $strippedContent = preg_replace($pattern, '', $strippedContent); // 删除 `<link>` 标签 | 158 | $strippedContent = preg_replace($pattern, '', $strippedContent); // 删除 `<link>` 标签 |
| 159 | $pattern = '/<footer\b[^>]*>(.*?)<\/footer>/s'; // 定义匹配`<script>`标签及其内容的正则表达式 | 159 | $pattern = '/<footer\b[^>]*>(.*?)<\/footer>/s'; // 定义匹配`<script>`标签及其内容的正则表达式 |
| 160 | $strippedContent = preg_replace($pattern, '', $strippedContent); // 删除`<script>`标签及其内容 | 160 | $strippedContent = preg_replace($pattern, '', $strippedContent); // 删除`<script>`标签及其内容 |
| 161 | -// $pattern = '/>([^<]+)</'; // 定义匹配中间内容不是标签的正则表达式 | ||
| 162 | -// $matches = array(); | ||
| 163 | -// preg_match_all($pattern, $strippedContent, $matches); | ||
| 164 | -// $textContentArray = array_filter($matches[1], function($item) { | ||
| 165 | -// $item = str_replace("\n", "", $item); | ||
| 166 | -// return !empty(trim($item)); | ||
| 167 | -// }); | ||
| 168 | - $pattern = '/<(\w+)[^>]*>(.*?)<\/\1>/s'; // Define the regular expression pattern | ||
| 169 | - preg_match_all($pattern, $strippedContent, $matches); // Match all tags and their content | ||
| 170 | - | ||
| 171 | - $tagContentArray = $matches[2]; // Extract the content part from the matches array | ||
| 172 | -// $textContentArray = array_values($textContentArray); | ||
| 173 | -// $uniqueArray = array_unique($textContentArray); | ||
| 174 | -// $textContentArray = array_values($uniqueArray); | ||
| 175 | - return $tagContentArray; | 161 | + $pattern = '/>([^<]+)</'; // 定义匹配中间内容不是标签的正则表达式 |
| 162 | + $matches = array(); | ||
| 163 | + preg_match_all($pattern, $strippedContent, $matches); | ||
| 164 | + $textContentArray = array_filter($matches[1], function($item) { | ||
| 165 | + $item = str_replace("\n", "", $item); | ||
| 166 | + return !empty(trim($item)); | ||
| 167 | + }); | ||
| 168 | + $textContentArray = array_values($textContentArray); | ||
| 169 | + $uniqueArray = array_unique($textContentArray); | ||
| 170 | + $textContentArray = array_values($uniqueArray); | ||
| 171 | + return $textContentArray; | ||
| 176 | } | 172 | } |
| 177 | 173 | ||
| 178 | /** | 174 | /** |
-
请 注册 或 登录 后发表评论