实现一个方法 formatHtml
实现如下变换:
const title = '<p>2x-y=0</p>'
formatHtml(title, 'A') // => '<p>A、2x-y=0</p>'
const title = '<p><strong>2x-y=0</strong></p>'
formatHtml(title, 'A') // => '<p><strong>A、2x-y=0</strong></p>'
最好用正则表达式,求助。
实现一个方法 formatHtml
实现如下变换:
const title = '<p>2x-y=0</p>'
formatHtml(title, 'A') // => '<p>A、2x-y=0</p>'
const title = '<p><strong>2x-y=0</strong></p>'
formatHtml(title, 'A') // => '<p><strong>A、2x-y=0</strong></p>'
最好用正则表达式,求助。
const formatHtml = (content, prefix) => content.replace(/<[^\/]*>(.*?)<\/.*?>/g, (sea,rel)=>sea.replace(rel,`${prefix}、${rel}`))
13 回答12.8k 阅读
8 回答2.6k 阅读
2 回答5.1k 阅读✓ 已解决
7 回答2k 阅读
3 回答2.2k 阅读✓ 已解决
5 回答897 阅读
3 回答1.1k 阅读✓ 已解决