我有一个MS Word格式的字典,我希望从字典条目中的任何段落中清除,并且只保留分隔任何两个字典条目的分段符。这就是现在字典的布局:
First picture http://img43.imageshack.us/img43/6476/snapshotpr.jpg
我需要一个宏或正则表达式,首先从文档中删除所有段落符号,这将产生这种布局:
Second picture http://img824.imageshack.us/img824/5219/snapshot1i.jpg
然后在下一步中只会在字典条目之前添加分段符号,这意味着只有在粗体短语后面跟着方括号中的拼音才能获得此布局:
Third picture http://img849.imageshack.us/img849/2003/snapshot2qf.jpg
答案 0 :(得分:2)
我使用this site来帮助我处理段落标记。
再次,我录制了一个宏,手动完成了4个查找/替换(两个步骤用于确保一个单词后跟一个方括号匹配)。这是宏:
Sub Separator()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^13"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.MatchFuzzy = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Bold = True
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
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Font.Bold = True
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "[a-z\-]@ \["
.Replacement.Text = "^p^&"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Font.Bold = True
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Bold = False
.Italic = False
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
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
让我知道是否有任何调整,我会尝试改变它:)
编辑:为连字符添加部分。