返回列表 发帖
strKey1 = "Locales"
strKey2 = "0000041c"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("a.txt", 1, false, -1)
txt = f.ReadAll : f.Close
pattern1 = "^ *\[" & strKey1 & "] *$"
pattern2 = "^ *" & strKey2 & " *=([^,]*,){2}([^,]*),([^,]*),.*$"
Set re = New RegExp
re.Pattern = pattern1 & "[\s\S]*?" & pattern2
re.IgnoreCase = true
re.MultiLine = true
If re.Test(txt) Then
        Set m = re.Execute(txt)(0)
        MsgBox "a=" & m.SubMatches(1) & " b=" & m.SubMatches(2)
End IfCOPY

TOP

回复 6# yuanyannian


    62行调用函数时,请参考ReplaceStr函数的方式传递实参,并在被调用的函数中设定函数返回值
在Function ProssLocales中不能再次打开INTL.INF文件,因为第47行已经打开并赋值给s了

TOP

回复 8# yuanyannian


    以下只是想当然,没做测试:
62~66行(未作容错处理,如果匹配不上,可能报下标越界):
LG = Split(ProssLocales(s), ",")
s = ReplaceStr(s, "\[LG_INSTALL_(" & LG(0) & "|" & LG(1) & ")]", "[DefaultInstall]")COPY
函数部分:
Function ProssLocales(ByVal s)
    strKey = "Locales"
    pattern1 = "^ *\[" & strKey & "] *$"
    pattern2 = "^ *" & sLoca & " *=([^,]*,){2}([^,]*,[^,]*),.*$"
    Set re = New RegExp
    re.Pattern = pattern1 & "[\s\S]*?" & pattern2
    re.IgnoreCase = true
    re.MultiLine = true
    For Each m in re.Execute(s)
        ProssLocales = m.SubMatches(1)
    Next
End FunctionCOPY

TOP

回复 10# yuanyannian


    CrLf老师一向谦虚:lol

TOP

返回列表