|
- Sub 顿号计数()
- Dim myPG As Paragraph, myRegEx As Object, myMatches As Object
- Dim i, s
- Set myRegEx = CreateObject("VBSCRIPT.REGEXP")
- i = 0
- For Each myPG In ActiveDocument.Paragraphs
- i = i + 1
- With myPG.Range
- s = Trim(Left(.Text, Len(.Text) - 1)) ' 去掉段落符和前后空格
- If Len(s) > 2 And Right(s, 1) = "。" And Not (Right(s, 2) Like "[))]。") Then
- With myRegEx
- .Pattern = "、"
- .IgnoreCase = False
- .MultiLine = False
- .Global = True
- Set myMatches = .Execute(myPG.Range.Text)
- End With
- If myMatches.Count > 0 Then
- Debug.Print "第 " & i & " 段有 " & myMatches.Count & " 个顿号" ' 数量较多,酌情处理
- End If
- End If
- End With
- Next myPG
- Set myPG = Nothing
- End Sub
复制代码 |
|