使用正则表达式替换-VBA [英] Using replace with regular expressions - VBA

查看:837
本文介绍了使用正则表达式替换-VBA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想格式化文本.我的意思是这样的: 我想改变一下:

I would like to format a text. I mean something like this: I'd like to transform this:

"something'text between apostrophes'text"

进入

"something 'text between apostrophes' text"

我想从两侧添加空格,但将te字符串保留在''中. 我试图这样做:

I want to add spaces from both sides, but keep te string in '' the same. I tried to do it like this:

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

但是它的结果是:

"something '*' text"

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

Arkusz1.Cells(1,1) contains the string I want to replace. Is it possible to do this? Thanks

推荐答案

您可以尝试以下正则表达式:

You can try this regex:

('[^']+')

并替换为:

" $1 "

Regex 101演示

这篇关于使用正则表达式替换-VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆