Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8088

Профиль | Отправить PM | Цитировать


Попробуйте так (на WSH):
Скрытый текст
Код: Выделить весь код
Option Explicit

Dim strSourceFile

Dim strContent
Dim arrPatterns
Dim strPattern


If WScript.Arguments.Count = 1 Then
	strSourceFile = WScript.Arguments.Item(0)
	
	With WScript.CreateObject("Scripting.FileSystemObject")
		If .FileExists(strSourceFile) Then
			With .OpenTextFile(strSourceFile)
				strContent = .ReadAll()
				.Close
			End With
		Else
			WScript.Echo "Can't find source file [" & strSourceFile & "]."
			WScript.Quit 2
		End If
	End With
	
	arrPatterns = Array( _
		"MEIBillAccFWDownLoad (\d{2}/\d{2} \d{2}:\d{2}:\d{2} ).* (Acceptor application software version is \d+)", _
		"MEIBillAccFWDownLoad (\d{2}/\d{2} \d{2}:\d{2}:\d{2} ).* (Acceptor variant firmware version is \d+)", _
		"MEIBillAccFWDownLoad (\d{2}/\d{2} \d{2}:\d{2}:\d{2} ).* (Acceptor serial number is \d+)" _
	)
	
	With WScript.CreateObject("VBScript.RegExp")
		.IgnoreCase = True
		.Global     = True
		
		For Each strPattern In arrPatterns
			.Pattern = strPattern
			
			If .Test(strContent) Then
				With .Execute(strContent)
					With .Item(.Count - 1).Submatches
						WScript.Echo .Item(0) & .Item(1)
					End With
				End With
			Else
				WScript.Echo "Can't find pattern [" & .Pattern & "] in source file [" & strSourceFile & "]."
			End If
		Next
	End With
Else
	WScript.Echo "Usage: cscript.exe //nologo " & WScript.ScriptName & " <Source file>"
	WScript.Quit 1
End If

WScript.Quit 0

Путь к исходному файлу указывается аргументом скрипта.

Последний раз редактировалось Iska, 16-04-2015 в 11:11. Причина: Добавлено «.Global = True»

Это сообщение посчитали полезным следующие участники:

Отправлено: 16:07, 15-04-2015 | #2