好的,我有这个文件sample.txt
("checkAssdMobileNo1".equals(ACTION)
("checkAssdMobileNo2".equals(ACTION)
("checkAssdMobileNo3".equals(ACTION)
("checkAssdMobileNo4".equals(ACTION)
("checkAssdMobileNo5".equals(ACTION)
("checkAssdMobileNo6".equals(ACTION)
如何仅输出以下内容:
checkAssdMobileNo1
checkAssdMobileNo2
checkAssdMobileNo3
checkAssdMobileNo4
checkAssdMobileNo5
checkAssdMobileNo6
我尝试使用以下代码,但它不会输出任何内容,我无法弄清楚我做错了什么:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set file = objFSO.OpenTextFile("sample.txt" , ForReading)
Const ForReading = 1
Dim re
Set re = new regexp
re.Pattern = """\w+?""[.]equals(ACTION)"
re.IgnoreCase = True
re.Global = True
Dim line
Do Until file.AtEndOfStream
line = file.ReadLine
For Each m In re.Execute(line)
Wscript.Echo m.Submatches(0)
Next
Loop
答案 0 :(得分:2)
你的正则表达式很接近,但遗漏了两件事:
ACTION
这样的事情应该有效:
re.Pattern = """(\w+?)""[.]equals\(ACTION\)"
答案 1 :(得分:1)