使用正则表达式从字符串中删除 HTML/XML 标记。
const stripHTMLTags = str => str.replace(/<[^>]*>/g, '');
// EXAMPLE
stripHTMLTags('
<em>lorem</em> <strong>ipsum</strong>
'); // 'lorem ipsum'
使用正则表达式从字符串中删除 HTML/XML 标记。
const stripHTMLTags = str => str.replace(/<[^>]*>/g, '');
// EXAMPLE
stripHTMLTags('
<em>lorem</em> <strong>ipsum</strong>
'); // 'lorem ipsum'