|
- Sub shish()
- Dim Arg As Range, S$, mt, mh, arr(), brr(), n%, m%, i%
- Set Arg = ActiveDocument.Content
- With CreateObject("VBScript.Regexp")
- .Global = True: .IgnoreCase = True: .MultiLine = True
- .Pattern = "^\d+[^【】]+?A[^【】]+?D[^【】]+?\r"
- ReDim Preserve arr(1 To .Execute(Arg).Count)
- For Each mt In .Execute(Arg)
- n = n + 1
- arr(n) = mt
- Next
- Arg = .Replace(Arg, "")
- .Pattern = "^\d+."
- Arg = .Replace(Arg, "")
- .Pattern = "^[a-z]\s*(?:(?!^[a-z]\s*).)+"
- ReDim Preserve brr(1 To .Execute(Arg).Count)
- For Each mh In .Execute(Arg)
- m = m + 1
- brr(m) = mh
- Next
- Arg.Delete
- End With
- Selection.Text = "单项选择题" & Chr(13)
- Selection.Collapse wdCollapseEnd
- For i = 1 To UBound(arr)
- S = S & arr(i) & "正确答案为:" & brr(i)
- Next
- Selection.Text = S
- Selection.HomeKey
- End Sub
复制代码 |
|