实现一个方法 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}`))
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.7k 阅读✓ 已解决
3 回答5.1k 阅读✓ 已解决
3 回答1.9k 阅读✓ 已解决