vbscript 12.检查作者贡献部分,作者名缩写是否跟前文部分作者名对应(名称缩写与前面部分的名称不一致)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 12.检查作者贡献部分,作者名缩写是否跟前文部分作者名对应(名称缩写与前面部分的名称不一致)相关的知识,希望对你有一定的参考价值。

Sub detectAuthorNameAbbr()
  Dim authorName As String

  authorName = getAuthourAbbr(ActiveDocument.Paragraphs(3).Range.Text)
Selection.HomeKey wdStory
    With Selection.Find
        .ClearFormatting
        .Text = "Author Contributions:"
        .Font.Bold = -1
        .MatchWildcards = False
        .Execute
        If .Found Then
        Selection.Paragraphs(1).Range.Select
            Call getErrorAuthourIndex(Selection.Text, authorName)
                
        End If
    End With
End Sub
Function getAuthourAbbr(str As String) As String
    Dim reg As New RegExp
    Dim matches
    With reg
        .Global = -1
        .Pattern = "[-]?[a-zA-Z]+"
        Set matches = .Execute(str)
    End With
    For Each m In matches
      If InStr(m, "-") > 0 Then
      getAuthourAbbr = getAuthourAbbr + Left(m, 2) + "."
      Else
        getAuthourAbbr = getAuthourAbbr + Left(m, 1) + "."
                       
        End If
    Next
End Function
Sub getErrorAuthourIndex(str As String, str1 As String)
  Dim Index, myL As Integer
  Dim myrange As Range
    Dim reg As New RegExp
    Dim matches
    Dim getErrorAuthourIndex As String
    With reg
        .Global = -1
        .Pattern = "([-]?[A-Z]\.)+ "
        Set matches = .Execute(str)
    End With
    If matches.count = 0 Then
        Selection.Range.HighlightColorIndex = wdRed
        Selection.Range.comments.Add Selection.Range, "Name abbreviations are not consistent with the names in front part"
        Exit Sub
    End If
    
    For Each m In matches
    
      If InStr(str1, Trim(m)) > 0 Then
       
    Else
        
        getErrorAuthourIndex = CStr(m.firstindex) + ";" + CStr(Len(m))
         arr1 = Split(getErrorAuthourIndex, ";")
                Index = CInt(arr1(0))
                myL = CInt(arr1(1))
            If Index > 0 Then
                Set myrange = ActiveDocument.Range(Selection.Range.Start + Index, Selection.Start + Index + myL)
                myrange.HighlightColorIndex = wdRed
                myrange.comments.Add myrange, "Name abbreviations are not consistent with the names in front part"
            End If
      End If
    Next
End Sub
Sub tttpp()
    MsgBox InStr("L.Z.P.S.R.S.L.S.", Trim("P.A.S."))
End Sub

以上是关于vbscript 12.检查作者贡献部分,作者名缩写是否跟前文部分作者名对应(名称缩写与前面部分的名称不一致)的主要内容,如果未能解决你的问题,请参考以下文章

vbscript 获取作者姓名电子邮件等

R 包的作者与贡献者 - 小代码贡献的角色是啥? [关闭]

vbscript 1.检测字里面作者名和邮箱是否跟管理平台上面一致

每个作者的 GIT 贡献(行)

检查文件夹中是不是存在任何文件(VBScript)

如何在 git 中显示作者贡献的统计信息?