[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. strKey1 = "Locales"
  2. strKey2 = "0000041c"
  3. Set fso = CreateObject("Scripting.FileSystemObject")
  4. Set f = fso.OpenTextFile("a.txt", 1, false, -1)
  5. txt = f.ReadAll : f.Close
  6. pattern1 = "^ *\[" & strKey1 & "] *$"
  7. pattern2 = "^ *" & strKey2 & " *=([^,]*,){2}([^,]*),([^,]*),.*$"
  8. Set re = New RegExp
  9. re.Pattern = pattern1 & "[\s\S]*?" & pattern2
  10. re.IgnoreCase = true
  11. re.MultiLine = true
  12. If re.Test(txt) Then
  13.         Set m = re.Execute(txt)(0)
  14.         MsgBox "a=" & m.SubMatches(1) & " b=" & m.SubMatches(2)
  15. End If
复制代码

TOP

回复 6# yuanyannian


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

TOP

回复 8# yuanyannian


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

TOP

回复 10# yuanyannian


    CrLf老师一向谦虚:lol

TOP

返回列表