【问题标题】:Using replace with regular expressions - VBA使用正则表达式替换 - VBA
【发布时间】:2018-03-23 23:20:09
【问题描述】:

我想格式化文本。我的意思是这样的: 我想改变这个:

"something'text between apostrophes'text"

进入

"something 'text between apostrophes' text"

我想从两边添加空格,但保持 '' 中的字符串相同。 我试着这样做:

  Arkusz1.Cells(1, 1).Replace What:="'*'" Replacement:=" '*' "

但它的结果是:

"something '*' text"

Arkusz1.Cells(1,1) 包含我要替换的string。是否有可能做到这一点? 谢谢

【问题讨论】:

    标签: regex vba format


    【解决方案1】:

    你可以试试这个正则表达式:

    ('[^']+')
    

    并替换为:

    " $1 "
    

    Regex 101 Demo

    【讨论】:

    • OP 是关于 VBA,而不是 VB.NET。
    猜你喜欢
    • 2019-02-28
    • 2014-03-29
    • 1970-01-01
    • 1970-01-01
    • 2019-01-24
    • 2019-06-26
    • 2019-01-08
    • 2020-11-05
    • 2014-06-01
    相关资源
    最近更新 更多