你可以试试这个:
<[A-Za-z\,\.\-\)\(\/\?\! ]{1,}>
而不是之前建议的发现<*>
乔治?
在新的 OP 编辑之后:
您可以尝试将其放入宏中:
Sub CommaAdder()
Selection.Find.ClearFormatting
Selection.Find.Font.Bold = True
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "<[A-Za-z]@>"
.Replacement.Text = "^&,"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
Selection.Find.Execute Replace:=wdReplaceAll
End With
With Selection.Find
.Text = ",([\)])"
.Replacement.Text = "\1,"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
Selection.Find.Execute Replace:=wdReplaceAll
End With
With Selection.Find
.Text = ",([\-\?\/\!\.\, ])"
.Replacement.Text = "\1"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
Selection.Find.Execute Replace:=wdReplaceAll
End With
With Selection.Find
.Text = "([A-Za-z]@ )"
.Replacement.Text = "\1,"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
Selection.Find.Execute Replace:=wdReplaceAll
End With
With Selection.Find
.Text = "( \,)([A-Za-z]@)"
.Replacement.Text = ", \2"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
Selection.Find.Execute Replace:=wdReplaceAll
End With
With Selection.Find
.Text = "\,\("
.Replacement.Text = "("
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
Selection.Find.Execute Replace:=wdReplaceAll
End With
With Selection.Find
.Text = "\, "
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
Selection.Find.Execute Replace:=wdReplaceAll
End With
With Selection.Find
.Text = " \,"
.Replacement.Text = ", "
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
Selection.Find.Execute Replace:=wdReplaceAll
End With
End Sub
我不知道如何编写宏,但我记录了一个替换来构建它,如果你明白一点,有 3 个替换一个接一个地进行。第一个查找所有粗体单词并在它们之间放置一个逗号,即使有)
or.
等。第二个专门查找我刚刚提到的删除该逗号的实例,以及我们有一个逗号后跟一个粗体的实例white space ,
,除了,)
在最后一个替换中解决的部分之外,它用代替替换它),
。
问题是,如果你有类似的东西:
这是大胆的,但不是这个
bold
之间的空白but
也具有bold
格式,它将在第二次替换时被删除。如果有一种方法可以找到部分粗体和部分非粗体的文本,那么就不会有任何问题。我正在尝试寻找解决方案,但如果此代码有任何问题,请告诉我。如果没有像这样粗体格式的空格,就不会有任何问题!
重新编辑:这现在也适用于粗体空间!虽然不是很整齐...