<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBScript: Замена символов в строке]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=8648&amp;type=atom" />
	<updated>2013-09-04T12:37:49Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=8648</id>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=75199#p75199" />
			<content type="html"><![CDATA[<p>все сработало отлично, видимо я что-то опять наворотил в коде !!!!</p>]]></content>
			<author>
				<name><![CDATA[d_alexei]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30241</uri>
			</author>
			<updated>2013-09-04T12:37:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=75199#p75199</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=75198#p75198" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Спасибо, но не совсем то.<br /> Мне надо заменить все email на пустое значение, т.е. на &quot;,,&quot;.</p></blockquote></div><p>Этого не было в техзадании. Было же приведено — конкретная строка.</p><div class="quotebox"><blockquote><p>Сейчас читаю регулярные выражения</p></blockquote></div><p>Всё верно. Пример шаблона привёл коллега <strong>Rumata</strong>.<br /></p><div class="codebox"><pre><code>Option Explicit

Const ForWriting = 2

Dim strContent
Dim objRegExp


Set objRegExp = WScript.CreateObject(&quot;VBScript.RegExp&quot;)

With objRegExp
    .Pattern = &quot;,[^,]+@[^,]+,&quot;
    .Global  = True
End With

With WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
    With .OpenTextFile(&quot;c:\file.csv&quot;)
        strContent = .ReadAll()
        .Close
    End With
    
    With .OpenTextFile(&quot;c:\file.log&quot;, ForWriting, True)
        .WriteLine objRegExp.Replace(strContent, &quot;,,&quot;)
        .Close
    End With
End With

Set objRegExp = Nothing

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>2013-09-04T12:29:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=75198#p75198</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=75197#p75197" />
			<content type="html"><![CDATA[<p>Спасибо, похоже то, что я и искал. Только теперь еще одна проблемка, не могу сообразить почему не пишет в файл замену. Код такой :</p><div class="codebox"><pre><code>Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set WshShell = CreateObject(&quot;WScript.Shell&quot;)
Set objRegExp = CreateObject(&quot;VBScript.RegExp&quot;)
Set objStream = objFSO.OpenTextFile(&quot;c:\file.csv&quot;)
Set Read_log = objFSO.OpenTextFile(&quot;c:\file.log&quot;, 2, True) 
objRegExp.Global = True
objRegExp.Pattern = &quot;[^,]+@[^,]+&quot;
Do While objStream.AtEndOfStream &lt;&gt; True
strLine = objStream.ReadLine

    WScript.Echo  &quot;strLine - &quot; &amp; strLine
    v1 = InStr (1,strLine,&quot;@&quot;) 
    If v1 &gt;0 Then 
    Set objMatches = objRegExp.Execute(strLine)
    strNewText = Replace(strLine, objRegExp.Pattern, &quot;&quot;, 1, 1)
    Read_log.WriteLine strNewText
    WScript.Echo &quot;objMatches.Count = &quot; &amp; objMatches.Count
    End if

Loop
objStream.Close</code></pre></div>]]></content>
			<author>
				<name><![CDATA[d_alexei]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30241</uri>
			</author>
			<updated>2013-09-04T12:29:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=75197#p75197</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=75196#p75196" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>d_alexei пишет:</cite><blockquote><p>Сейчас читаю регулярные выражения, но тоже не совсем то, или я не умею их использовать. Все, что по шаблону @mail ищется и заменяется легко, а вот что стоит до @ не видится.</p></blockquote></div><p>Вам нужно в строке &quot;что-то-в-начале,нечто@еще-нечто,что-то-в-конце&quot; найтит подстроку вида &quot;нечто@еще-нечто&quot; и удалить ее. Если Вы посмотрите внимательно, то увидите, что удаляемая часть находится между запятыми и идентифицируется наличием &quot;собачки&quot; @. Вот и ищите - &quot;не-запятые-собачка-не-запятые&quot;: <br /></p><div class="codebox"><pre><code>[^,]+@[^,]+</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Rumata]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24846</uri>
			</author>
			<updated>2013-09-04T12:04:40Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=75196#p75196</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=75195#p75195" />
			<content type="html"><![CDATA[<p>Спасибо, но не совсем то.<br />Мне надо заменить все email на пустое значение, т.е. на &quot;,,&quot;. Т.е. все, что находится между запятыми и если содержит @ , то надо убрать. Сейчас читаю регулярные выражения, но тоже не совсем то, или я не умею их использовать. Все, что по шаблону @mail ищется и заменяется легко, а вот что стоит до @ не видится.</p>]]></content>
			<author>
				<name><![CDATA[d_alexei]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30241</uri>
			</author>
			<updated>2013-09-04T11:32:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=75195#p75195</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=75192#p75192" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>Option Explicit

Const ForWriting = 2

With WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
    With .OpenTextFile(&quot;c:\file.csv&quot;)
        strContent = .ReadAll()
        .Close
    End With
    
    With .OpenTextFile(&quot;c:\file.log&quot;, ForWriting, True)
        .WriteLine Replace(strContent, &quot;1@mail&quot;, &quot;&quot;)
        .Close
    End With
End With

WScript.Quit 0
</code></pre></div><p>Не проверялось.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2013-09-04T10:25:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=75192#p75192</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBScript: Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=75190#p75190" />
			<content type="html"><![CDATA[<p>Понимаю, что тема много раз описана, но не нашел ответ на свой вопрос :<br />есть csv файл? в нем надо найти в строках все &quot;,1@mail,&quot; и заменить на &quot;,,&quot;<br /><span style="color: Green"><strong>П</strong></span>ытаюсь сделать так :<br /></p><div class="codebox"><pre><code>Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set WshShell = CreateObject(&quot;WScript.Shell&quot;)
Set objStream = objFSO.OpenTextFile(&quot;c:\file.csv&quot;)
Set Read_log = objFSO.OpenTextFile(&quot;c:\file.log&quot;, 2, True) 
Do While objStream.AtEndOfStream &lt;&gt; True
strLine = objStream.ReadLine
    v1 = InStr (1,strLine,&quot;@&quot;) 
    If v1 &gt;0 Then 
    Read_log.WriteLine Replace(strLine, &quot;@&quot;, &quot;&quot;, 1, 1)
    End if
Loop
objStream.Close</code></pre></div><p><span style="color: Green"><strong>С</strong></span>ам символ @ он ищет и меняет, но мне надо все, что находится между запятыми стереть и поставить просто ,,</p><p><span style="color: Green"><strong>П</strong></span>одскажите плиз!</p>]]></content>
			<author>
				<name><![CDATA[d_alexei]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30241</uri>
			</author>
			<updated>2013-09-04T09:15:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=75190#p75190</id>
		</entry>
</feed>
