不知是否编码问题,第二个文本始终得不到正确结果,VBS也歇菜了。以下代码针对第一个文本:- Dim objFSO,objRegEx
- Const ForReading = 1
- sFile = "a.txt"
-
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set oFile = objFSO.OpenTextFile(sFile, 1, TristateTrue)
- colLines = oFile.ReadAll
- oFile.Close
-
- Set objRegEx = CreateObject("VBScript.RegExp")
- objRegEx.Global = True
- objRegEx.IgnoreCase = True
- objRegEx.Pattern = "MY_THUMB.*jpg"
- Set Matches = objRegEx.Execute(colLines)
-
- For Each objMatch in Matches
- aryLines = aryLines & objMatch & vbCrLf
- Next
-
- aryLines = Split(aryLines, ";")
-
- For i = 0 To Ubound(aryLines) - 1
- var_1 = Replace(Replace(Split(aryLines(i), ",")(1),".jpg", ""),"'", "")
- var_2 = Replace(Replace(Split(aryLines(i), ",")(2),"'",""), ")", "")
- strLine = "/Ref:abc /Rename:" & var_1 & " " & var_2 & vbCrLf
- strLines = strLines & strLine & vbCrLf
- Next
-
- Wscript.Echo strLines
-
- Set objFSO = Nothing
- Set objRegEx = Nothing
复制代码
[ 本帖最后由 asnahu 于 2009-10-14 18:01 编辑 ] |