<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS: Поиск текста в строке]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=9496&amp;type=atom" />
	<updated>2014-04-17T11:53:58Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=9496</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Поиск текста в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=81897#p81897" />
			<content type="html"><![CDATA[<p>Огромное спасибо!!! Вечером буду пробовать.</p>]]></content>
			<author>
				<name><![CDATA[legroman]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31843</uri>
			</author>
			<updated>2014-04-17T11:53:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=81897#p81897</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Поиск текста в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=81862#p81862" />
			<content type="html"><![CDATA[<p>Пробуйте:<br /></p><div class="codebox"><pre><code>Option Explicit

Dim strSourceFile

Dim arrContent
Dim strLine


strSourceFile = &quot;E:\Песочница\0374\text.txt&quot;

With WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
    If .FileExists(strSourceFile) Then
        With .OpenTextFile(strSourceFile)
            arrContent = Split(.ReadAll(), vbCrLf)
            .Close
        End With
        
        With WScript.CreateObject(&quot;VBScript.RegExp&quot;)
            .IgnoreCase = True
            
            For Each strLine In arrContent
                .Pattern = &quot;^Имя Сотрудника.*(Вася|Петя).*$&quot;
                
                If .Test(strLine) Then
                    WScript.Echo &quot;действие 1&quot;
                End If
                
                .Pattern = &quot;^Имя Сотрудника.*Иван.*$&quot;
                
                If .Test(strLine) Then
                    WScript.Echo &quot;действие 2&quot;
                End If
            Next
        End With
    Else
        WScript.Echo &quot;Source file [&quot; &amp; strSourceFile &amp; &quot;] not found.&quot;
        WScript.Quit 1
    End If
End With

WScript.Quit 0
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2014-04-17T04:36:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=81862#p81862</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS: Поиск текста в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=81851#p81851" />
			<content type="html"><![CDATA[<p>Уважаемые форумчане.&nbsp; Помогите пожалуйста чайнику. Нужен VBS скрипт ищущий в текстовом файле строку, а потом в этой строке слово. Допустим имеем файл <strong>text.txt</strong> нам известно что где то в нем есть строка которая начинается словами &quot;<strong>Имя Сотрудника</strong>&quot; надо найти эту строку и если в ней будут слова &quot;<strong>Вася</strong>&quot; или &quot;<strong>Петя</strong>&quot; тогда выполнить <strong>действие 1</strong>, если же в ней встретится слово &quot;<strong>Иван</strong>&quot; то выполнить&nbsp; <strong>действие 2</strong>.&nbsp; Заранее благодарен за помощь.</p>]]></content>
			<author>
				<name><![CDATA[legroman]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31843</uri>
			</author>
			<updated>2014-04-16T17:24:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=81851#p81851</id>
		</entry>
</feed>
