vbscript 单词提取

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 单词提取相关的知识,希望对你有一定的参考价值。

Sub extract_1()
    'Selection.MoveDown unit:=wdParagraph, Extend:=wdExtend
    a = Split(Selection.Paragraphs(1).Range.Text, Chr(13))(0)
    a = reg_arr("\[\[(.*?)\]\]", a)
    str1 = ""
    For i = 1 To UBound(a)
        str1 = str1 & a(i)
        If Right(a(i), 1) = "。" Or Right(a(i), 1) = "!" Then
            str1 = str1
        Else
            str1 = str1 & "。"
        End If
    Next
    
    Selection.Paragraphs(1).Range.Select
    'Selection.Delete
    Selection.TypeText Text:=str1
    '---
    If MsgBox("next?", vbOKCancel) = vbOK Then
        Selection.MoveDown unit:=wdParagraph
        If judge_pa Then
            extract_1
        Else
            For i = 1 To 15
                Selection.MoveDown unit:=wdParagraph
                If judge_pa Then
                    extract_1
                    Exit For
                End If
            Next
        End If
    End If
End Sub
Function judge_pa()
    a = Split(Selection.Paragraphs(1).Range.Text, Chr(13))(0)
    If a = "" Then
        judge_pa = False
    Else
        judge_pa = True
    End If
End Function
Function reg_arr(reg_1, str_1)
    '获得的arr,从序号1开始取(即第2个),因0的位置(即第一个)为空
    Dim y
    str_spt = "@-@"
    Set Regex2 = CreateObject("vbscript.regexp")
    With Regex2
        .Global = True
        .IgnoreCase = True
        .Pattern = reg_1
        Set matches2 = Regex2.Execute(str_1)
'        reg_arr = matches2(0).submatches(0)
        For Each m In matches2
            y = y & str_spt & m.submatches(0)
        Next
        reg_arr = Split(y, str_spt)
    End With
    Set Regex2 = Nothing
    Set matches2 = Nothing
End Function

以上是关于vbscript 单词提取的主要内容,如果未能解决你的问题,请参考以下文章

vbscript 单个单词查缩写

vbscript 单词get_title11

vbscript 单词add_link

vbscript excel从单词中获取形式

vbscript 单词select_and_cp

“vbscript”查找行有相似的单词用冒号分隔“:”[关闭]