我想找到字符串“no”的所有出现。 +1到1之间的整数。 然后删除“不”。并在paranthesis:“(4)”或“(67)”之间包装整数/ s。例如。 “第34号”应成为“(34)”。
我似乎有多个问题(Word 2010):
我的代码确实添加了paranthesis,但是在活动文档的开头和结尾。如何让它包裹数字呢?
With Selection.Find
.Text = "n[or]. [1-9]"
.Replacement.Text = "XXXXX"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.InsertBefore ("(")
Selection.InsertAfter (")")
Selection.Find.Execute Replace:=wdReplaceAll
答案 0 :(得分:0)
尝试使用以下解决方案:
With Selection.Find
.Text = "(No.)( )([1-9]{1;2})"
.Replacement.Text = "(\3)"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll