需要使用 php 从包含 html 个实体和元素的字符串中提取纯文本
Need to extract plain text from the string containing html entities and elements using php
$string = "<h2> <div class="OutlineElement Ltr SCX116040423" style="margin: 0px; padding: 0px; font-family: 'Segoe UI', Tahoma, Verdana, sans-serif; font-size: 8px; font-weight: normal;"> <p class="MsoNormal">Residents of the northeast are discovering that Branford Hall has become one of the fastest and most effective ways to begin a high growth career.<o:p>"
$string = preg_replace("/&#?[a-z0-9]+;/i","",$string);
我需要纯文本输出:
Residents of the northeast are discovering that Branford Hall has become one of the fastest and most effective ways to begin a high growth career.
请帮助我更正 preg_replace 正则表达式?
PHP有一些内置函数应该更方便:
$string = strip_tags(html_entity_decode($string));
$string = "<h2> <div class="OutlineElement Ltr SCX116040423" style="margin: 0px; padding: 0px; font-family: 'Segoe UI', Tahoma, Verdana, sans-serif; font-size: 8px; font-weight: normal;"> <p class="MsoNormal">Residents of the northeast are discovering that Branford Hall has become one of the fastest and most effective ways to begin a high growth career.<o:p>"
$string = preg_replace("/&#?[a-z0-9]+;/i","",$string);
我需要纯文本输出:
Residents of the northeast are discovering that Branford Hall has become one of the fastest and most effective ways to begin a high growth career.
请帮助我更正 preg_replace 正则表达式?
PHP有一些内置函数应该更方便:
$string = strip_tags(html_entity_decode($string));