我想格式化文字。我的意思是这样的: 我想改变这个:
"something'text between apostrophes'text"
进入
"something 'text between apostrophes' text"
我想从两边添加空格,但保持te字符串相同。 我试着这样做:
Arkusz1.Cells(1, 1).Replace What:="'*'" Replacement:=" '*' "
但其结果是:
"something '*' text"
Arkusz1.Cells(1,1)
包含我要替换的string
。是否有可能做到这一点?
感谢
答案 0 :(得分:3)
你可以试试这个正则表达式:
('[^']+')
并替换为:
" $1 "
示例来源
Dim Regex As System.Text.RegularExpressions.Regex
Dim SubjectString As String = "something 'text between apostrophes' text"
Dim ResultString As String = Regex.Replace(SubjectString, "('[^']+')", " $1 ")
Console.WriteLine(ResultString)