0

我有一本 MS Word 格式的字典,我想从字典条目中的任何分段符中清除它,并且只保留分隔任何两个字典条目的分段符。这是字典的布局现在的样子:

第一张图片http://img43.imageshack.us/img43/6476/snapshotpr.jpg

我需要一个宏或一个正则表达式,它首先从文档中删除所有分节符,这将产生这种布局:

第二张图片http://img824.imageshack.us/img824/5219/snapshot1i.jpg

然后在下一步中仅在字典条目之前添加分段符,这意味着仅在粗体短语之前,然后是方括号中的音标,以获得此布局:

第三张图片 http://img849.imageshack.us/img849/2003/snapshot2qf.jpg

4

1 回答 1

2

我使用这个网站来帮助我处理段落标记。

同样,我用 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

结束子

让我知道是否有任何需要调整的地方,我会尝试更改它:)

编辑:为连字符添加了部分。

于 2013-04-14T19:52:22.263 回答