excel - 将字符串的一部分从一组字符删除到另一个字符
问题描述
我有一个 Excel 工作表,我想删除一些 HTML 标记。我的问题是一些标签不仅仅是简单的<div>
标签,而是有额外的字符,比如<div class="ExternalClassEA74AB3F178E48EDAD3BDE4FC90B1182">
替换,<div
直到我们到达>
标签的结尾。如何用“”替换这样的字符串部分。谢谢。
解决方案
Sub RemoveDivs()
Dim html$
html = "Some other text<div class=""ExternalClassEA74AB3F178E48EDAD3BDE4FC90B1182""> and here too"
With CreateObject("VBScript.RegExp")
.Pattern = "<div.*?>": .Global = True
html = .Replace(html, "")
End With
MsgBox html
End Sub
推荐阅读
- github - 使用 Brew 连接到 Github 时遇到问题
- python - 为什么访问数据框和列表中的值不同?
- javascript - 浏览器不会用包含文件替换包含文件
- awk - AWK:当第 1 列和第 2 列匹配时删除所有行
- powershell - 即使捕获到异常,Pester 也无法通过测试
- java - Golang 和 apache AB
- c - 如何将 Lchild 和 Rchild 添加到现有节点?
- rest - 使用 Xamarin.Forms 从 Furl 返回 Null 值,请求在 Postmaster 中有效
- sql-server - Excel 从电子邮件收件箱到 SQL Server 数据库
- r - ggplot2/knitr:geom_col 在 PDF 中显示中断,但在 RStudio/HTML 中不显示