【问题标题】:Replace several substrings to several substrings in single string using vba (excel)使用vba(excel)将多个子字符串替换为单个字符串中的多个子字符串
【发布时间】:2018-05-02 20:49:36
【问题描述】:

请告诉我是否可以使用 VBA (excel) 在组合了多个不同替换的字符串中执行替换?

例如:

text = Replace(text, find1, res1)
text = Replace(text, find2, res2)

实例:

text = Replace(text, " ", " ")
text = Replace(text, "&", "&")
text = Replace(text, "&lt", "<")

也许是正则表达式?

【问题讨论】:

  • 是的,您可以完全按照您的示例显示的那样做——使用三个语句。除非您遗漏了更多细节...

标签: regex excel string vba replace


【解决方案1】:

嵌套它们:

Text = Replace(Replace(Replace(Text, "&nbsp;", " "), "&amp;", "&"), "&lt", "<")

【讨论】:

    猜你喜欢
    • 2016-09-10
    • 2017-12-06
    • 2021-06-13
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-09
    相关资源
    最近更新 更多