<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: не понимаю как работать с RegExReplace в Ahk]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=16342</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16342&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: не понимаю как работать с RegExReplace в Ahk».]]></description>
		<lastBuildDate>Tue, 11 May 2021 20:51:17 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: не понимаю как работать с RegExReplace в Ahk]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147817#p147817</link>
			<description><![CDATA[<p>На самом деле не совсем:<br /></p><div class="codebox"><pre><code>File := &quot;Text.txt&quot;
Text=
(

Всем привет! 

   Я Олег

Я помыл своего кота.

)
FileDelete, % File
FileAppend, % Text, % File

FileRead, Out, Text.txt
MsgBox, 0, Исходный текст:, % Out
Out2 := RegExReplace(Out, &quot;m)^\s+&quot;)
MsgBox, 0, Обработанный текст:, % &quot;|&quot; Out2 &quot;|&quot;
Return</code></pre></div><p>Как видно, удалились пробелы из второй непустой строки, что не входило в задачу, и последний лишний перенос строки остался.<br />А вот так вообще не будет удалять:<br /></p><div class="codebox"><pre><code>text =
(

Всем привет! 

Я Олег

Я помыл своего кота.

)
FileOpen(&quot;text.txt&quot;, &quot;w&quot;).Write(text)
FileRead, textFromFile, text.txt
MsgBox, % &quot;|&quot; RegExReplace(textFromFile, &quot;m)^\s+&quot;) &quot;|&quot;</code></pre></div><p>Всё зависит, какой вариант переноса строк используется, `r`n или `n.<br />Для обоих вариантов есть опция `a:<br /></p><div class="codebox"><pre><code>text =
(

Всем привет! 

Я Олег

Я помыл своего кота.

)
FileOpen(&quot;text.txt&quot;, &quot;w&quot;).Write(text)
FileRead, textFromFile, text.txt
MsgBox, % &quot;|&quot; RegExReplace(textFromFile, &quot;`am)^\s+&quot;) &quot;|&quot;</code></pre></div><p>Но так последний перенос строки тоже не удалился.<br />Тут всё немного хитрее.<br /></p><div class="codebox"><pre><code>text =
(

Всем привет! 

   Я Олег

Я помыл своего кота.

)
MsgBox, % &quot;|&quot; . RegExReplace(text, &quot;^(\h*(\R|$))+|\R\h*(?=\R|$)&quot;) . &quot;|&quot;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 11 May 2021 20:51:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147817#p147817</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: не понимаю как работать с RegExReplace в Ahk]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147814#p147814</link>
			<description><![CDATA[<p>Очень интересно почему так вышло.<br />Up: Ну так чтение из файла иную кодировку имеет и пустые строки удаляет.</p><div class="codebox"><pre><code>File := &quot;Text.txt&quot;	; Файл для чтения строк.

IfNotExist, % File	; Проверить его существование, если нет - создать и записать строки:
{
 Text=
 (

Всем привет! 

Я Олег

Я помыл своего кота.
 )
 FileAppend,% Text, % File
}


FileRead, Out, Text.txt		; Прочитать файл.
Return


F2::
MsgBox, 0, Исходный текст:, % Out
Out2 := RegExReplace(Out, &quot;m)^\s+&quot;)
MsgBox, 0, Обработанный текст:, % Out2
Return</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (__Михаил__)]]></author>
			<pubDate>Tue, 11 May 2021 19:31:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147814#p147814</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: не понимаю как работать с RegExReplace в Ahk]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147812#p147812</link>
			<description><![CDATA[<p><strong>__Михаил__</strong><br /></p><div class="codebox"><pre><code>out =
(

Всем привет! 

Я Олег

Я помыл своего кота.

)
MsgBox, % &quot;|&quot; RegExReplace(out, &quot;m)^\s+&quot;, &quot;&quot;) &quot;|&quot;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 11 May 2021 19:10:32 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147812#p147812</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: не понимаю как работать с RegExReplace в Ahk]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147811#p147811</link>
			<description><![CDATA[<p>Мне не помогло. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br /></p><div class="codebox"><pre><code>out =
(

Всем привет! 

Я Олег

Я помыл своего кота.

)
MsgBox, % &quot;|&quot; RegExReplace(out, &quot;m) \R(\R)*+&quot;, &quot;`n&quot;) &quot;|&quot;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 11 May 2021 19:09:22 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147811#p147811</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: не понимаю как работать с RegExReplace в Ahk]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147810#p147810</link>
			<description><![CDATA[<p>Удалось таким способом:<br /></p><div class="codebox"><pre><code>Out := RegExReplace(out, &quot;m)^\s+&quot;, &quot;&quot;)</code></pre></div><p>Т.е. пробел после опции &#039;m)&#039; не нужен.</p>]]></description>
			<author><![CDATA[null@example.com (__Михаил__)]]></author>
			<pubDate>Tue, 11 May 2021 19:07:26 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147810#p147810</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: не понимаю как работать с RegExReplace в Ahk]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147809#p147809</link>
			<description><![CDATA[<p><strong>__Михаил__</strong></p><p>Понял. Спасибо<br />Это мне и правда помогло.<br /></p><div class="codebox"><pre><code>RegExReplace(out, &quot;m) \R(\R)*+&quot;, &quot;`n&quot;)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Clannad5)]]></author>
			<pubDate>Tue, 11 May 2021 18:47:32 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147809#p147809</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: не понимаю как работать с RegExReplace в Ahk]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147808#p147808</link>
			<description><![CDATA[<p>Вроде как нужно использовать &#039;m) &#039; для мульти-строчного текста.<br />Примерный шаблон (не работает как нужно):</p><div class="codebox"><pre><code>File := &quot;Text.txt&quot;	; Файл для чтения строк.

IfNotExist, % File	; Проверить его существование, если нет - создать и записать строки:
{
 Text=
 (

Всем привет! 

Я Олег

Я помыл своего кота.
 )
 FileAppend,% Text, % File
}

FileRead, out, Text.txt		; Прочитать файл.
Return

F2::
out := RegExReplace(out, &quot;m) \s+&quot;, &quot;.&quot;)
MsgBox, % out
Return</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (__Михаил__)]]></author>
			<pubDate>Tue, 11 May 2021 18:42:03 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147808#p147808</guid>
		</item>
		<item>
			<title><![CDATA[AHK: не понимаю как работать с RegExReplace в Ahk]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147807#p147807</link>
			<description><![CDATA[<p>Есть файл Text.txt:</p><div class="codebox"><pre><code>
Всем привет! 

Я Олег

Я помыл своего кота.
</code></pre></div><p>Есть команда в Ahk:</p><div class="codebox"><pre><code>
FileRead, out, Text.txt
out := RegExReplace(out, &quot;\s+$&quot;, &quot;&quot;)
</code></pre></div><p>Результат следующий:</p><div class="codebox"><pre><code>
Всем привет! 

Я Олег

Я помыл своего кота.
</code></pre></div><p>То есть, результат не изменился.<br />Пробую тоже самое на <a href="https://regex101.com/">https://regex101.com/</a><br />Вот что выходит: <a href="https://regex101.com/r/708VHz/1">https://regex101.com/r/708VHz/1</a></p><p>Вопрос: Это с AHK что-то не так или я делаю что-то не так?</p><p>Цель: Удалить пустые строки, которые могут включать как пробелы так и табуляции.</p>]]></description>
			<author><![CDATA[null@example.com (Clannad5)]]></author>
			<pubDate>Tue, 11 May 2021 17:29:28 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147807#p147807</guid>
		</item>
	</channel>
</rss>
