【发布时间】:2021-07-21 19:22:54
【问题描述】:
我有这个 html 字符串
<span style="font-size:25px;border-radius: 10px;">John Doe</span>
来自回复。我尝试使用此代码仅获取 John Doe
const testt = String(response.body)
const match = testt.match(/^<span style="font-size:25px;border-radius: 10px;">(.*)<\/span>$/);
console.log('match', match[1]);
我在日志中收到null。
【问题讨论】:
-
它周围可能有额外的空白。试试
test1 = response.body.trim()
标签: javascript html string match response