<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Поиск и замена нескольких строк]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=7273&amp;type=atom" />
	<updated>2013-02-19T23:51:59Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=7273</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69651#p69651" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>
Str := &quot;1001&quot; , List := [&quot;Первое&quot;, &quot;Второе&quot;, &quot;Третье&quot;, &quot;Четвёртое&quot;]
    for index, value in list
        SubStr(Str, index, 1) = 1 ? Res .= value . &quot;+&quot;
MsgBox  %Res%
</code></pre></div><p>или лучше без массива:<br /></p><div class="codebox"><pre><code>
Str := &quot;1010&quot; , List := &quot;Первое|Второе|Третье|Четвёртое&quot;
    Loop, Parse, List, |
        SubStr(Str, A_Index, 1) = 1 ? Res .= A_LoopField . &quot;+&quot;
MsgBox  %Res%
</code></pre></div><p>плодить лишние index и value <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-02-19T23:51:59Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69651#p69651</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69650#p69650" />
			<content type="html"><![CDATA[<p>Прикольно, я и незнал что тернарные операторы используются внутри RegEx для присваивания.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-02-19T23:33:32Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69650#p69650</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69649#p69649" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>someVar:=0101, pattern:=&quot;O)(1)&quot;, sArr:=[&quot;Первое&quot;, &quot;Второе&quot;, &quot;Третье&quot;, &quot;Четвёртое&quot;]

While, RegExMatch(someVar, pattern, outVar, outVar.Pos(1) ? outVar.Pos(1)+outVar.Len:1)
   outList.=sArr[outVar.Pos]

MsgBox, % 262 . (outList ? 208:160)
      , % outList ? &quot;Result:&quot;:&quot;Oops!&quot;
      , % outList ? outList:&quot;No matches&quot;
      , % (outList ? 3:0) . .5</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2013-02-19T23:25:28Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69649#p69649</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69647#p69647" />
			<content type="html"><![CDATA[<p>Настолько сложно, что даже непонимаю как это использовать <img src="//forum.script-coding.com/img/smilies/neutral.png" width="15" height="15" /><br />Можно на примере:<br /></p><div class="codebox"><pre><code>Str := &quot;0101&quot;
****
Res := &quot;ВтороеЧетвёртое&quot;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-02-19T22:41:22Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69647#p69647</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69646#p69646" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>...попроще, без массивов...</p></blockquote></div><div class="codebox"><pre><code>str:=&quot;ICQ - 00011110111000111101&quot;, pattern:=&quot;(1)&quot;, cnt:=0

While, match:=RegExMatch(str, pattern, outVar, match ? match+StrLen(outVar):1)
{
   cnt++
   While, outVar%A_Index%
      tmp:=&quot;match position: &quot;match+(StrLen(outVar)-StrLen(outVar%A_Index%))&quot; (&quot;cnt &quot;)`n&quot;
   outList.=RTrim(tmp, &quot;`n&quot;)&quot;`n&quot;, tmp:=&quot;&quot;
}

MsgBox, % 262 . (outList ? 208:160)
      , % outList ? &quot;Result:&quot;:&quot;Oops!&quot;
      , % outList ? RTrim(outList, &quot;`n&quot;):&quot;No matches&quot;
      , % (outList ? 3:0) . .5</code></pre></div><p>Или:</p><div class="codebox"><pre><code>str:=&quot;ICQ - 00011110111000111101&quot;, pattern:=&quot;O)(1)&quot;

While, RegExMatch(str, pattern, outVar , outVar.Pos(1) ? outVar.Pos(1)+outVar.Len:1)
   outList.=&quot;match position: &quot;outVar.Pos &quot; (&quot;A_Index &quot;)`n&quot;

MsgBox, % 262 . (outList ? 208:160)
      , % outList ? &quot;Result:&quot;:&quot;Oops!&quot;
      , % outList ? RTrim(outList, &quot;`n&quot;):&quot;No matches&quot;
      , % (outList ? 3:0) . .5</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2013-02-19T22:09:02Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69646#p69646</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69637#p69637" />
			<content type="html"><![CDATA[<p>Как бы мне на выходе из этой строки:<br /><em>Str := &quot;1010&quot;</em><br />попроще, без массивов и.т.п. получить:<br /><em>Res := &quot;ПервоеТретье&quot;</em><br />или:<br /><em>Str := &quot;0101&quot;<br />Res := &quot;ВтороеЧетвёртое&quot;</em></p><p>В строке могут быть только 1 и 0, если все нули то результат пустой.<br />------------------------------------<br />ничего хорошего пока непридумал:<br /></p><div class="codebox"><pre><code>Str := &quot;1010&quot;
MsgBox  % RegExReplace(RegExReplace(RegExReplace(SubStr(Str,1,1),&quot;1&quot;,&quot;Первое&quot;)SubStr(Str,2,1),&quot;1&quot;,&quot;Второе&quot;)
 . RegExReplace(RegExReplace(SubStr(Str,3,1),&quot;1&quot;,&quot;Третье&quot;)SubStr(Str,4,1),&quot;1&quot;,&quot;Четвёртое&quot;),&quot;0&quot;)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-02-19T16:57:34Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69637#p69637</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69632#p69632" />
			<content type="html"><![CDATA[<p><em>Слона</em> (!), и не заметил. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2013-02-19T02:16:14Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69632#p69632</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69629#p69629" />
			<content type="html"><![CDATA[<p>Коллега <strong>Grey</strong> перемудрил слегка <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p><div class="codebox"><pre><code>Mod = Win+Alt+Shift+Ctrl+Результат
list := {Win: &quot;#&quot;, Ctrl: &quot;^&quot;, Alt: &quot;!&quot;, Shift: &quot;+&quot;}

for k, v in list
   StringReplace, Mod, Mod, %k%+, %v%

MsgBox  %Mod%</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2013-02-18T22:30:50Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69629#p69629</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69626#p69626" />
			<content type="html"><![CDATA[<p>Вот так упростили <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-02-18T20:33:43Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69626#p69626</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69624#p69624" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>str:=&quot;Alt+Shift+Ctrl+Win+result&quot;, d:=&quot;+&quot;
arr:={Win:&quot;#&quot;, Alt:&quot;!&quot;, Shift:&quot;+&quot;, Ctrl:&quot;^&quot;}

StringSplit, outArr, str, % d

Loop, % outArr0-1
   StringReplace, str, str, % outArr%A_Index% d, % arr[outArr%A_Index%]

MsgBox, 262144, % A_Space, % str</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2013-02-18T20:28:38Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69624#p69624</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69623#p69623" />
			<content type="html"><![CDATA[<p>Всю голову сломал, подскажите как упростить код:<br /></p><div class="codebox"><pre><code>
Mod = Win+Alt+Shift+Ctrl+Результат
StringReplace, Pref, Mod, Win+, #
StringReplace, Pref, Pref, Ctrl+, ^
StringReplace, Pref, Pref, Alt+, !
StringReplace, Pref, Pref, Shift+, +
MsgBox  %Pref%
</code></pre></div><p>на каком месте будет например Win+ неизвестно.<br />пока вот так получилось:<br /></p><div class="codebox"><pre><code>Mod = Win+Alt+Shift+Ctrl+Результат
MsgBox  % RegExReplace(RegExReplace(RegExReplace(RegExReplace(Mod,&quot;Shift\+&quot;,&quot;+&quot;),&quot;Alt\+&quot;,&quot;!&quot;),&quot;Ctrl\+&quot;,&quot;^&quot;),&quot;Win\+&quot;,&quot;#&quot;)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-02-18T19:20:04Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69623#p69623</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69540#p69540" />
			<content type="html"><![CDATA[<p>Нет, это я поспешил.<br /></p><div class="codebox"><pre><code>MsgBox,, % &quot;&quot; := RegExMatch(&quot;str1`nstr2`nstr3`nstr4&quot;, &quot;`am)(?:.*\R){2}\K.+$&quot;, m),  % m</code></pre></div>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2013-02-15T11:55:02Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69540#p69540</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69539#p69539" />
			<content type="html"><![CDATA[<p>Спасибо! <br />С одной строкой я конечно погорячился....</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-02-15T11:45:36Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69539#p69539</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69538#p69538" />
			<content type="html"><![CDATA[<p>C учётом, что RegExMatch возвращает номер символа с которого начинается соответствие выражению, а команда MsgBox не может быть записана в одну строку с выражением&nbsp; — в одну строку не получится.<br /></p><div class="codebox"><pre><code>text := &quot;
(
str1
str2
str3
str4
)&quot;
RegExMatch(text, &quot;`am)(?:.*\R){2}\K.+$&quot;, m)
MsgBox % m</code></pre></div>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2013-02-15T11:38:37Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69538#p69538</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и замена нескольких строк]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=69537#p69537" />
			<content type="html"><![CDATA[<p>А можно ли по аналогии:<br /></p><div class="codebox"><pre><code>
Loop, parse, clipboard, `n, `r
{
Str := A_LoopField 
if A_Index = 3
break
}
MsgBox %Str%
</code></pre></div><p>вернуть строку по её номеру?<br /></p><div class="codebox"><pre><code>MsgBox % RegExMatch (clipboard, &quot;***&quot;, 3строка)
</code></pre></div><p>&quot;одной строкой кода&quot;</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-02-15T11:15:59Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=69537#p69537</id>
		</entry>
</feed>
