发布网友 发布时间:2022-04-25 17:57
共1个回答
热心网友 时间:2023-10-23 01:02
Const ForReading = 1, ForWriting = 2
Dim fso, f, oFile, str
oFile = "D:\a.txt" '这里修改为你的文件路径
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(oFile, ForReading)
str = f.ReadAll
f.Close
'MsgBox str
str = RegExpReplace("<pr_code>.+</pr_code>", str, "<pr_code></pr_code>")
str = RegExpReplace("<pr_date>.+</pr_date>", str, "<pr_date></pr_date>")
'MsgBox str
Set f = fso.OpenTextFile(oFile, ForWriting, True)
f.Write str
f.Close
Function RegExpReplace(patrn, strOrig, strReplace)
Dim regEx, Match, Matches ' Create variable.
Set regEx = New RegExp ' Create a regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
RetStr = regEx.Replace(strOrig, strReplace)
Set regEx = Nothing追问代码写上注解说明,不要等网友采纳。