首页 > 解决方案 > QRegExp 用法:如何从 html 字符串中获取图像名称?

问题描述

html = ... <span>emoticon12</span><img src="qrc:\res\emoticon\emo12.gif" width="20" height="20"/><span>emoticon8</span><div>...</div><img src="qrc:\res\emoticon\emo8.gif" width="20" height="20"/>...<img src="qrc:\res\emoticon\emo9.gif" width="20" height="20"/>...

如何使用 html 中的 QRegExp 将所有图像名称作为 QStringList 获取?

结果 = emo12.gif、emo8.gif、emo9.gif

我不能做正则表达式。

标签: regexqt5

解决方案


在这种情况下,您可以使用以下模式解析它们:(匹配在第一个捕获组中)

(\w+\.\w+)"

演示:https ://regex101.com/r/gAzPJo/1/


推荐阅读