<?xml version="1.0" encoding="utf-8"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Форум программистов и сисадминов Киберфорум - Блоги - Jack Famous</title>
		<link>https://www.cyberforum.ru/blogs/1808109/</link>
		<description>КиберФорум - форум программистов, системных администраторов, администраторов баз данных, компьютерный форум, форум по электронике и бытовой технике, обсуждение софта. Бесплатная помощь в решении задач по программированию и наукам, решение проблем с компьютером, операционными системам</description>
		<language>ru</language>
		<lastBuildDate>Sat, 05 Sep 2026 16:32:42 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>https://www.cyberforum.ru//cyberstatic.net/images/misc/rss.jpg</url>
			<title>Форум программистов и сисадминов Киберфорум - Блоги - Jack Famous</title>
			<link>https://www.cyberforum.ru/blogs/1808109/</link>
		</image>
		<item>
			<title>Как использовать командную строку? | VBA. How to use Cmd. Function «Shell()», Object «WshShell» and others</title>
			<link>https://www.cyberforum.ru/blogs/1808109/8544.html</link>
			<pubDate>Wed, 22 May 2024 09:04:47 GMT</pubDate>
			<description>Начинаю цикл тем о командной строке — чтобы зафиксировать полученный опыт для себя и других. 
Шапка...</description>
			<content:encoded><![CDATA[<div>Начинаю цикл тем о командной строке — чтобы зафиксировать полученный опыт для себя и других.<br />
Шапка темы (этот пост) будет обновляться — здесь будут фиксироваться готовые приёмы и задаваться очередные вопросы для последующего разбора в постах темы.<br />
Оставляю за собой право на ошибки и неточности. Прошу сообщать при их обнаружении.<br />

			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Function Shell()</div>
				   <div class="spoiler-body">
					   <a rel="nofollow noopener noreferrer" href="https://vremya-ne-zhdet.ru/vba-excel/funktsiya-shell/" target="_blank" title="https://vremya-ne-zhdet.ru/vba-excel/funktsiya-shell/">VBA Excel. Функция Shell</a><br />
<u>Основных моменты:</u><br />
     • не требует подключения дополнительных библиотек. Не помню, в какой из обязательных (для работы VBA) она находится.<br />
     • возвращает ID запущенного процесса. Можно сравнить ответ функции с ID, указанным в &quot;Подробностях&quot; Диспетчера задач (на скринах ниже).<br />
     • асинхронная. То есть, после ОТПРАВКИ команды на исполнение, код VBA продолжит работу НЕМЕДЛЕННО, не дожидаясь окончания выполнения. Практически никогда такое поведение не нужно и опасно. Фиксится использованием оболочки из API (покажу далее). В качестве универсального костыльного варианта — можно проверять ожидаемый итог исполнения команды (например, файлов в папке должно стать больше на один) в бесконечном цикле, пока итог не совпадёт. Как вы понимаете, применить этот костыль можно далеко не всегда.<br />
     • второй параметр — видимость окна. Например, 0 (или <font color="Blue">vbHide</font>) отвечает за его скрытие, а 1 (или <font color="Blue">vbNormalFocus</font>) — за передачу фокуса (переключение). Если вам нужно просто выполнить команду, то используйте 0 (если вы вызываете приложение, то оно будет запущено и, немедленно, скрыто), а, если вам нужно работать с, например, приложением, запущенным по команде, через его (приложения) интерфейс — нужно передать фокус.<br />
     • просто отправляет команду на исполнение. Никак не работает с ответом на команду.
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Пример разных вызовов штатного блокнота (путь должен существовать)</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="174059078"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="174059078" style="height: 126px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Private</span> <span class="kw2">Sub</span> Test_Shell()
<span class="kw4">Dim</span> n&amp;
&nbsp; &nbsp; n = Shell(<span class="st0">&quot;C:\WINDOWS\NOTEPAD.EXE&quot;</span>, vbHide) &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">' Run Notepad and Hide it immediately</span>
 &nbsp; &nbsp;n = Shell(<span class="st0">&quot;C:\WINDOWS\NOTEPAD.EXE&quot;</span>, vbNormalFocus) &nbsp;<span class="co1">' Run Notepad and set it Active</span>
 &nbsp; &nbsp;Debug.<span class="kw4">Print</span> n
<span class="kw3">End</span> <span class="kw2">Sub</span></pre></td></tr></table></div></td></tr></tbody></table></div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Скрины сравнения ответа Shell() и ID из диспетчера</div>
				   <div class="spoiler-body">
					   <a href="https://www.cyberforum.ru/blog_attachment.php?attachmentid=8709&amp;d=1716368652" rel="Lightbox" id="attachment8709" ><img src="https://www.cyberforum.ru/blog_attachment.php?attachmentid=8709&amp;thumb=1&amp;d=1716368652" class="thumbnail" border="0" alt="Нажмите на изображение для увеличения
Название: Shell_NotePad_Immediate.png
Просмотров: 250
Размер:	6.5 Кб
ID:	8709" style="margin: 5px" /></a><a href="https://www.cyberforum.ru/blog_attachment.php?attachmentid=8708&amp;d=1716368652" rel="Lightbox" id="attachment8708" ><img src="https://www.cyberforum.ru/blog_attachment.php?attachmentid=8708&amp;thumb=1&amp;d=1716368652" class="thumbnail" border="0" alt="Нажмите на изображение для увеличения
Название: Shell_NotePad.png
Просмотров: 272
Размер:	20.1 Кб
ID:	8708" style="margin: 5px" /></a>
				   </div>
			   </div>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Функция для синхронизации Shell() с помощью API (x64 Only)</div>
				   <div class="spoiler-body">
					   <u>Пример вызова:</u> <font color="Blue">Debug.Print PRDX_API_ShellAndWait(&quot;C:\WINDOWS\NOTEPA D.EXE&quot;, True, True)</font><div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="936695064"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="936695064" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="kw2">Public</span> Const PROCESS_QUERY_INFORMATION&amp; = &amp;H400, SYNCHRONIZE = &amp;H100000, STILL_ACTIVE&amp; = &amp;H103
<span class="kw2">Public</span> Const vc_Cyc_2bil&amp; = 2000000000
<span class="co1">'==================================================================================================</span>
<span class="kw2">Private</span> <span class="kw4">Declare</span> PtrSafe <span class="kw2">Function</span> OpenProcess Lib <span class="st0">&quot;kernel32.dll&quot;</span> (<span class="kw4">ByVal</span> dwDesiredAccess <span class="kw4">As</span> <span class="kw1">Long</span>, <span class="kw4">ByVal</span> bInheritHandle <span class="kw4">As</span> <span class="kw1">Long</span>, <span class="kw4">ByVal</span> dwProcessId <span class="kw4">As</span> <span class="kw1">Long</span>) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw2">Private</span> <span class="kw4">Declare</span> PtrSafe <span class="kw2">Function</span> GetExitCodeProcess Lib <span class="st0">&quot;kernel32.dll&quot;</span> (<span class="kw4">ByVal</span> hProcess <span class="kw4">As</span> <span class="kw1">Long</span>, lpExitCode <span class="kw4">As</span> <span class="kw1">Long</span>) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_API_ShellAndWait(sCommand$, <span class="kw4">Optional</span> MsgTrue <span class="kw4">As</span> <span class="kw1">Boolean</span>, <span class="kw4">Optional</span> MsgFalse <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Boolean</span>
<span class="kw4">Dim</span> p&amp;, c&amp;, e&amp;, n&amp;
&nbsp;
p = Shell(sCommand, 0): &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">If</span> (p = 0) <span class="kw3">Then</span> <span class="kw3">If</span> MsgFalse <span class="kw3">Then</span> MsgBox <span class="st0">&quot;Shell with command:&quot;</span> &amp; vbLf &amp; sCommand &amp; vbLf &amp; <span class="st0">&quot;is OUT!&quot;</span>, vbCritical, <span class="st0">&quot;PRDX_API_ShellAndWait&quot;</span>: <span class="kw2">Exit</span> <span class="kw2">Function</span> <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
p = OpenProcess(PROCESS_QUERY_INFORMATION, 0, p): &nbsp; <span class="kw3">If</span> (p = 0) <span class="kw3">Then</span> <span class="kw3">If</span> MsgFalse <span class="kw3">Then</span> MsgBox <span class="st0">&quot;OpenProcess of Shell with command:&quot;</span> &amp; vbLf &amp; sCommand &amp; vbLf &amp; <span class="st0">&quot;is OUT!&quot;</span>, vbCritical, <span class="st0">&quot;PRDX_API_ShellAndWait&quot;</span>: <span class="kw2">Exit</span> <span class="kw2">Function</span> <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> vc_Cyc_2bil
&nbsp; &nbsp; e = GetExitCodeProcess(p, c): <span class="kw3">DoEvents</span>: &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> (e = 0) <span class="kw3">Then</span> <span class="kw3">If</span> MsgFalse <span class="kw3">Then</span> MsgBox <span class="st0">&quot;GetExitCodeProcess of Shell with command:&quot;</span> &amp; vbLf &amp; sCommand &amp; vbLf &amp; <span class="st0">&quot;is OUT!&quot;</span>, vbCritical, <span class="st0">&quot;PRDX_API_ShellAndWait&quot;</span>: <span class="kw2">Exit</span> <span class="kw2">Function</span> <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp; &nbsp; <span class="kw3">If</span> (c &lt;&gt; STILL_ACTIVE) <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw3">For</span>
<span class="kw3">Next</span> n
&nbsp;
<span class="kw3">If</span> (n &gt; vc_Cyc_2bil) <span class="kw3">Then</span> n = 0: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">If</span> MsgFalse <span class="kw3">Then</span> MsgBox <span class="st0">&quot;Cycle to GetExitCodeProcess of Shell with command:&quot;</span> &amp; vbLf &amp; sCommand &amp; vbLf &amp; <span class="st0">&quot;was LOOPED!&quot;</span>, vbCritical, <span class="st0">&quot;PRDX_API_ShellAndWait&quot;</span>: <span class="kw2">Exit</span> <span class="kw2">Function</span> <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp;
PRDX_API_ShellAndWait = <span class="kw5">True</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> MsgTrue <span class="kw3">Then</span> MsgBox <span class="st0">&quot;Shell with command:&quot;</span> &amp; vbLf &amp; sCommand &amp; vbLf &amp; <span class="st0">&quot;was succsessfully finished in &quot;</span> &amp; Format$(n, <span class="st0">&quot;#,#&quot;</span>) &amp; <span class="st0">&quot; Cycles!&quot;</span>, vbInformation, <span class="st0">&quot;PRDX_API_ShellAndWait&quot;</span>
<span class="kw3">End</span> <span class="kw2">Function</span></pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
				   </div>
			   </div></div>

]]></content:encoded>
			<dc:creator>Jack Famous</dc:creator>
			<guid isPermaLink="true">https://www.cyberforum.ru/blogs/1808109/8544.html</guid>
		</item>
		<item>
			<title><![CDATA[Как работать с архивами? | VBA. How to work with archives. Method «Shell32.Namesp&shy;ace», Program «7z» and others]]></title>
			<link>https://www.cyberforum.ru/blogs/1808109/8543.html</link>
			<pubDate>Wed, 22 May 2024 08:58:29 GMT</pubDate>
			<description>Начинаю цикл тем о работе с архивами — чтобы зафиксировать полученный опыт для себя и других. 
  ...</description>
			<content:encoded><![CDATA[<div>Начинаю цикл тем о работе с архивами — чтобы зафиксировать полученный опыт для себя и других.<br />
   Шапка темы (этот пост) будет обновляться — здесь будут фиксироваться готовые приёмы и задаваться очередные вопросы для последующего разбора в постах темы.<br />
   Оставляю за собой право на ошибки и неточности. Прошу сообщать при их обнаружении.<br />
   Пока набросаю черновик — займусь, как будет время.<br />
<br />
<b>7z:</b><br />
    Внутри архива пути начинаются с имён папок (или сразу имён файлов) и это имеет значение при удалении. То есть, чтобы удалить файлы <font color="Blue">test.txt</font> <b>везде</b> мне нужен ключ <b><font color="blue">-r</font></b> (рекурсивный поиск), если <b>только в корне архива</b> — без этого ключа и та же маска <font color="blue">test.txt</font>, если же нужно удалить это файл только <b>в конкретной папке</b>, то путь загоняем в маску: <font color="blue">fold1\fold2\test.txt</font>.<br />
    Чтобы удалить <b>все файлы</b> (<b>вместе с папкой</b>, к сожалению или счастью) из папки, маску делаем: <font color="blue">fold1\fold2\*</font>. Вариант <font color="blue">fold1\fold2\*.xml</font> также удалит и саму папку <font color="blue">fold2</font>, если в ней только xml-файлы.</div>

]]></content:encoded>
			<dc:creator>Jack Famous</dc:creator>
			<guid isPermaLink="true">https://www.cyberforum.ru/blogs/1808109/8543.html</guid>
		</item>
		<item>
			<title><![CDATA[Хранение структурированн&shy;­­ых данных (таблиц) в памяти и скорость доступа к ним | How to keep Data in RAM and get it Fast]]></title>
			<link>https://www.cyberforum.ru/blogs/1808109/8472.html</link>
			<pubDate>Thu, 21 Mar 2024 08:07:50 GMT</pubDate>
			<description>*Приветствую!* 
В одном из моих проектов возникла необходимость хранить в памяти несколько...</description>
			<content:encoded><![CDATA[<div><b>Приветствую!</b><br />
В одном из моих проектов возникла необходимость хранить в памяти несколько небольших одинаковых по полям табличек и очень часто получать из них информацию по индексам. То есть, вводные данные — 3 числа: номер таблицы, номер строки, номер столбца.<br />
<br />
Решил проверить, что быстрее и делюсь с вами(Планета и Кибер).
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Часть 1. 1D массив с 2D массивами или один 2D массив. Второй вариант в 2 раза быстрее.</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="898652794"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="898652794" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="kw2">Private</span> <span class="kw2">Sub</span> Test_TypeOfSafe()
<span class="kw4">Dim</span> a(), aa(), a2D_Full(), aKoef&amp;()
<span class="kw4">Dim</span> t!, r&amp;, c&amp;, n&amp;, m&amp;, p&amp;
Const rA&amp; = 3, cA&amp; = 2, mult&amp; = 10, nCyc&amp; = 100000000 <span class="co1">' 100 mln</span>
&nbsp;
<span class="co1">' Prepare ===========================================================</span>
<span class="co1">' Arr2D =========================================</span>
<span class="kw4">ReDim</span> a(rA, cA)
&nbsp;
<span class="kw3">For</span> c = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(a, 2)
&nbsp; &nbsp; <span class="kw3">For</span> r = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(a, 1)
&nbsp; &nbsp; &nbsp; &nbsp; a(r, c) = 10 * r + c
&nbsp; &nbsp; <span class="kw3">Next</span> r
<span class="kw3">Next</span> c
&nbsp;
<span class="co1">' Arr1D with Arr2D ==============================</span>
<span class="kw4">ReDim</span> aa(mult)
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aa)
&nbsp; &nbsp; aa(n) = a
<span class="kw3">Next</span> n
&nbsp;
<span class="co1">' Full Arr2D ====================================</span>
<span class="kw4">ReDim</span> aKoef(mult)
<span class="kw4">ReDim</span> a2D_Full(mult * rA, cA)
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> mult &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">' 1 &nbsp;2 &nbsp;3 &nbsp;4 &nbsp;5 &nbsp; 6 &nbsp; 7 &nbsp; 8 &nbsp; 9 &nbsp; 10</span>
 &nbsp; &nbsp;aKoef(n) = rA * (n - 1) <span class="co1">' 0, 3, 6, 9, 12, 15, 18, 21, 24, 27</span>
 &nbsp; &nbsp;<span class="kw3">For</span> c = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(a, 2)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">For</span> r = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(a, 1)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a2D_Full(aKoef(n) + r, c) = a(r, c)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Next</span> r
&nbsp; &nbsp; <span class="kw3">Next</span> c
<span class="kw3">Next</span> n
&nbsp;
<span class="co1">' Speed Test ========================================================</span>
<span class="co1">' ArrArr ========================================</span>
t = Timer
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> nCyc
&nbsp; &nbsp; &nbsp; &nbsp; p = aa(mult)(rA, cA)
&nbsp; &nbsp; <span class="kw3">Next</span> n
Debug.<span class="kw4">Print</span> <span class="st0">&quot;ArrArr&quot;</span>, Format$(Timer - t, <span class="st0">&quot;0.0&quot;</span>), p &nbsp; <span class="co1">' 3.4 | 32</span>
&nbsp;
<span class="co1">' a2D_Full ======================================</span>
t = Timer
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> nCyc
&nbsp; &nbsp; &nbsp; &nbsp; p = a2D_Full(aKoef(mult) + rA, cA)
&nbsp; &nbsp; <span class="kw3">Next</span> n
Debug.<span class="kw4">Print</span> <span class="st0">&quot;a2D_Full&quot;</span>, Format$(Timer - t, <span class="st0">&quot;0.0&quot;</span>), p &nbsp;<span class="co1">' 1.7 | 32</span>
&nbsp;
&nbsp;
<span class="co1">' Show Arrays =======================================================</span>
<span class="co1">'Worksheets.add</span>
<span class="co1">'Cells(1, 1).Resize(UBound(a, 1), UBound(a, 2)).Value2 = a</span>
<span class="co1">'Cells(1, 2 + UBound(a, 2)).Resize(UBound(a2D_Full, 1), UBound(a2D_Full, 2)).Value2 = a2D_Full</span>
<span class="kw3">End</span> <span class="kw2">Sub</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
'==================================================================================================</pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>В дальнейшем планирую проверить скорость <b><font color="Blue">ENum</font></b> и <b><font color="blue">User Defined Type</font></b> — для превращения безликих индексов в осмысленные параметры.</div>

]]></content:encoded>
			<dc:creator>Jack Famous</dc:creator>
			<guid isPermaLink="true">https://www.cyberforum.ru/blogs/1808109/8472.html</guid>
		</item>
		<item>
			<title>Лемматизация текста в Excel</title>
			<link>https://www.cyberforum.ru/blogs/1808109/7982.html</link>
			<pubDate>Mon, 06 Mar 2023 07:11:25 GMT</pubDate>
			<description>*Приветствую!* 
 
Коротко: лемма - это  начальная, словарная форма слова...</description>
			<content:encoded><![CDATA[<div><b>Приветствую!</b><br />
<br />
Коротко: лемма - это  <a rel="nofollow noopener noreferrer" href="https://ru.wikipedia.org/wiki/%D0%9B%D0%B5%D0%BC%D0%BC%D0%B0_(%D0%BB%D0%B8%D0%BD%D0%B3%D0%B2%D0%B8%D1%81%D1%82%D0%B8%D0%BA%D0%B0)" target="_blank" title="https://ru.wikipedia.org/wiki/%D0%9B%D0%B5%D0%BC%D0%BC%D0%B0_(%D0%BB%D0%B8%D0%BD%D0%B3%D0%B2%D0%B8%D1%81%D1%82%D0%B8%D0%BA%D0%B0)">начальная, словарная форма слова</a>. Леммы нужны [среди прочего] для того, чтобы &quot;нормализовать&quot; строки данных и найти точные совпадения там где до преобразования их не было.<br />
Например: &quot;<i>вася дал маше яблоки</i>&quot; может быть преобразовано в &quot;<b>вася дать маша яблоко</b>&quot; и строка &quot;<i>василий давал машеньке яблочко</i>&quot; также может быть преобразовано в эту конструкцию из лемм отдельных слов. Таким образом, мы получим точное совпадение там, где раньше его не было.<br />
Данный справочник является [например] одним из инструментов нечёткого поиска.<br />
<br />
Справочником является переработанный словарь от <b><a rel="nofollow noopener noreferrer" href="http://opencorpora.org/dict.php" target="_blank" title="http://opencorpora.org/dict.php">OpenCorpora</a></b> и состоит из 2ух версий (обе в формате txt, который можно открыть в Excel):
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">OpenCorpora</div>
				   <div class="spoiler-body">
					   Переработанный xml по ссылке со структурой: лемма - варианты (кросс-таблица).<br />

			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Скрин</div>
				   <div class="spoiler-body">
					   <a href="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7965&amp;d=1678086340" rel="Lightbox" id="attachment7965" ><img src="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7965&amp;thumb=1&amp;d=1678086340" class="thumbnail" border="0" alt="Нажмите на изображение для увеличения
Название: OpenCorpora.PNG
Просмотров: 299
Размер:	10.8 Кб
ID:	7965" style="margin: 5px" /></a>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Файл</div>
				   <div class="spoiler-body">
					   <a href="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7963&amp;d=1678086340" >OpenCorpora.7z</a>
				   </div>
			   </div>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">List</div>
				   <div class="spoiler-body">
					   Так как у разных лемм могут быть общие варианты, создан плоский список &quot;вариант-лемма&quot; (не влезет на лист т.к. более 3 млн строк), в котором варианты не повторяются (взят первый). Именно этот список я использую для замены слов на их леммы
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Скрин</div>
				   <div class="spoiler-body">
					   <img src="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7964&amp;d=1678086340" border="0" alt="Название: List.PNG
Просмотров: 2013

Размер: 6.8 Кб" style="margin: 5px" />
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Файл</div>
				   <div class="spoiler-body">
					   <a href="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7962&amp;d=1678086340" >List.7z</a>
				   </div>
			   </div>
				   </div>
			   </div>На Планете есть моя тема с аналогичным названием (найти не составит труда) и подробным разбором. Ссылки на неё тут запрещены.</div>

]]></content:encoded>
			<dc:creator>Jack Famous</dc:creator>
			<guid isPermaLink="true">https://www.cyberforum.ru/blogs/1808109/7982.html</guid>
		</item>
		<item>
			<title><![CDATA[Сцепить элементы каждой "строки "двумерного массива с выравниванием "друг по другом"]]></title>
			<link>https://www.cyberforum.ru/blogs/1808109/7916.html</link>
			<pubDate>Wed, 25 Jan 2023 16:19:26 GMT</pubDate>
			<description>*Приветствую!* 
Функция нужна для отчётов: Debug.Print, MsgBox или печать лога в текстовый файл, но...</description>
			<content:encoded><![CDATA[<div><b>Приветствую!</b><br />
Функция нужна для отчётов: Debug.Print, MsgBox или печать лога в текстовый файл, но &quot;чтоб как таблица было&quot;.
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Скрин</div>
				   <div class="spoiler-body">
					   <img src="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7892&amp;d=1674663548" border="0" alt="Название: Снимок.PNG
Просмотров: 3049

Размер: 2.3 Кб" style="margin: 5px" />
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Код</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="608851456"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="608851456" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_Arr2D_To1D_AlignmentStrings(a2D, <span class="kw4">Optional</span> <span class="kw4">ByVal</span> nSpaces&amp; = 1) <span class="kw4">As</span> <span class="kw1">String</span>()
<span class="kw4">Dim</span> aStr$(), aLen&amp;(), aSps$()
<span class="kw4">Dim</span> tx$, r&amp;, c&amp;, l&amp;
&nbsp;
<span class="kw4">ReDim</span> aStr(<span class="kw4">UBound</span>(a2D, 1))
<span class="kw4">ReDim</span> aLen(<span class="kw4">UBound</span>(a2D, 2))
&nbsp;
<span class="kw3">For</span> r = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(a2D, 1)
&nbsp; &nbsp; <span class="kw3">For</span> c = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(a2D, 2)
&nbsp; &nbsp; &nbsp; &nbsp; a2D(r, c) = Trim$(a2D(r, c))
&nbsp; &nbsp; &nbsp; &nbsp; l = Len(a2D(r, c))
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> l &gt; aLen(c) <span class="kw3">Then</span> aLen(c) = l
&nbsp; &nbsp; <span class="kw3">Next</span> c
<span class="kw3">Next</span> r
&nbsp;
<span class="kw4">ReDim</span> aSps(<span class="kw4">UBound</span>(aLen))
&nbsp;
<span class="kw3">For</span> c = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aLen)
&nbsp; &nbsp; aSps(c) = Space$(aLen(c) + nSpaces)
<span class="kw3">Next</span> c
&nbsp;
<span class="kw3">For</span> r = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(a2D, 1)
&nbsp; &nbsp; <span class="kw3">For</span> c = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(a2D, 2)
&nbsp; &nbsp; &nbsp; &nbsp; tx = aSps(c)
&nbsp; &nbsp; &nbsp; &nbsp; Mid$(tx, 1, Len(a2D(r, c))) = a2D(r, c)
&nbsp; &nbsp; &nbsp; &nbsp; aStr(r) = aStr(r) &amp; tx
&nbsp; &nbsp; <span class="kw3">Next</span> c
&nbsp;
&nbsp; &nbsp; aStr(r) = Trim$(aStr(r))
<span class="kw3">Next</span> r
&nbsp;
PRDX_Arr2D_To1D_AlignmentStrings = aStr
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'--------------------------------------------------------------------------------------------------</span>
<span class="kw2">Private</span> <span class="kw2">Sub</span> Test_PRDX_Arr2D_To1D_AlignmentStrings()
<span class="kw4">Dim</span> x
&nbsp;
<span class="kw4">ReDim</span> x(3, 3)
x(1, 1) = <span class="st0">&quot;My dream&quot;</span>: &nbsp; x(1, 2) = <span class="st0">&quot;is&quot;</span>: &nbsp; &nbsp; x(1, 3) = <span class="st0">&quot;to fly&quot;</span>
x(2, 1) = <span class="st0">&quot;Over&quot;</span>: &nbsp; &nbsp; &nbsp; x(2, 2) = <span class="st0">&quot;the&quot;</span>: &nbsp; &nbsp;x(2, 3) = <span class="st0">&quot;rainbow&quot;</span>
x(3, 1) = <span class="st0">&quot;So&quot;</span>: &nbsp; &nbsp; &nbsp; &nbsp; x(3, 2) = <span class="st0">&quot;&quot;</span>: &nbsp; &nbsp; &nbsp; x(3, 3) = <span class="st0">&quot;high&quot;</span>
&nbsp;
Debug.<span class="kw4">Print</span> Join(PRDX_Arr2D_To1D_AlignmentStrings(x, 3), vbLf)
<span class="kw3">End</span> <span class="kw2">Sub</span></pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div><br />
<br />

			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">UPD 26/01/2023:</div>
				   <div class="spoiler-body">
					   
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Описание обновления</div>
				   <div class="spoiler-body">
					   • Ускорил в 4 раза.<br />
• Теперь можно использовать в качестве разделителя элементов любой символ или даже строку. До общей длины по столбцу элементы по прежнему &quot;добиваются&quot; пробелами. Можно и это сделать переменной, но практического смысла пока не вижу.<br />
• Теперь функция возвращает длину [каждой] строки сцепки, а строковый массив для заполнения, нужно передать.
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Скрин</div>
				   <div class="spoiler-body">
					   <img src="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7894&amp;d=1674723802" border="0" alt="Название: Снимок2.PNG
Просмотров: 1873

Размер: 2.5 Кб" style="margin: 5px" />
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Код</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="918337258"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="918337258" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_Arr2D_To1D_AlignmentStrings(a2D, a1D_Res$(), <span class="kw4">Optional</span> <span class="kw4">ByVal</span> sepJoin$ = <span class="st0">&quot; &quot;</span>) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> aLen&amp;(), tx$, txSp$, r&amp;, c&amp;, l&amp;, lSep&amp;
&nbsp;
<span class="kw4">ReDim</span> a1D_Res(<span class="kw4">UBound</span>(a2D, 1))
<span class="kw4">ReDim</span> aLen(<span class="kw4">UBound</span>(a2D, 2))
&nbsp;
<span class="kw3">For</span> c = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(a2D, 2)
&nbsp; &nbsp; <span class="kw3">For</span> r = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(a2D, 1)
&nbsp; &nbsp; &nbsp; &nbsp; l = Len(a2D(r, c))
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> l &gt; aLen(c) <span class="kw3">Then</span> aLen(c) = l
&nbsp; &nbsp; <span class="kw3">Next</span> r
<span class="kw3">Next</span> c
&nbsp;
l = 0
<span class="kw3">For</span> c = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aLen)
&nbsp; &nbsp; l = l + aLen(c)
<span class="kw3">Next</span> c
&nbsp;
lSep = Len(sepJoin)
l = l + lSep * (<span class="kw4">UBound</span>(aLen) - 1)
PRDX_Arr2D_To1D_AlignmentStrings = l
txSp = Space$(l): l = 0
&nbsp;
<span class="kw3">For</span> r = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(a2D, 1)
&nbsp; &nbsp; tx = txSp
&nbsp;
&nbsp; &nbsp; <span class="kw3">For</span> c = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(a2D, 2) - 1
&nbsp; &nbsp; &nbsp; &nbsp; Mid$(tx, l + 1, aLen(c)) = a2D(r, c): &nbsp; l = l + aLen(c)
&nbsp; &nbsp; &nbsp; &nbsp; Mid$(tx, l + 1, lSep) = sepJoin: &nbsp; &nbsp; &nbsp; &nbsp;l = l + lSep
&nbsp; &nbsp; <span class="kw3">Next</span> c
&nbsp;
&nbsp; &nbsp; Mid$(tx, l + 1, aLen(c)) = a2D(r, c)
&nbsp; &nbsp; a1D_Res(r) = tx: l = 0
<span class="kw3">Next</span> r
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'--------------------------------------------------------------------------------------------------</span>
<span class="kw2">Private</span> <span class="kw2">Sub</span> TestSpeed_PRDX_Arr2D_To1D_AlignmentStrings()
<span class="kw4">Dim</span> bef$(), aft$()
<span class="kw4">Dim</span> t!, n&amp;, l&amp;
Const nCyc&amp; = 1000000
&nbsp;
<span class="kw4">ReDim</span> bef(3, 3)
bef(1, 1) = <span class="st0">&quot;My dream&quot;</span>: bef(1, 2) = <span class="st0">&quot;is&quot;</span>: &nbsp; bef(1, 3) = <span class="st0">&quot;to fly&quot;</span>
bef(2, 1) = <span class="st0">&quot;Over&quot;</span>: &nbsp; &nbsp; bef(2, 2) = <span class="st0">&quot;the&quot;</span>: &nbsp;bef(2, 3) = <span class="st0">&quot;rainbow&quot;</span>
bef(3, 1) = <span class="st0">&quot;So&quot;</span>: &nbsp; &nbsp; &nbsp; bef(3, 2) = <span class="st0">&quot;&quot;</span>: &nbsp; &nbsp; bef(3, 3) = <span class="st0">&quot;high&quot;</span>
&nbsp;
t = Timer
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> nCyc
&nbsp; &nbsp; &nbsp; &nbsp; l = PRDX_Arr2D_To1D_AlignmentStrings(bef, aft, <span class="st0">&quot; — &quot;</span>) &nbsp;<span class="co1">' 3.23</span>
 &nbsp; &nbsp;<span class="kw3">Next</span> n
Debug.<span class="kw4">Print</span> Format$(Timer - t, <span class="st0">&quot;0.00&quot;</span>), l
Debug.<span class="kw4">Print</span> Join(aft, vbLf)
<span class="kw3">End</span> <span class="kw2">Sub</span></pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
				   </div>
			   </div></div>

]]></content:encoded>
			<dc:creator>Jack Famous</dc:creator>
			<guid isPermaLink="true">https://www.cyberforum.ru/blogs/1808109/7916.html</guid>
		</item>
		<item>
			<title>Обрезать строку по разделителю / Cut String by Separator</title>
			<link>https://www.cyberforum.ru/blogs/1808109/7892.html</link>
			<pubDate>Wed, 11 Jan 2023 14:10:56 GMT</pubDate>
			<description>*Приветствую!* 
Делюсь функцией обрезки строки по заданному разделителю с 2мя обязательными и 4мя...</description>
			<content:encoded><![CDATA[<div><b>Приветствую!</b><br />
Делюсь функцией обрезки строки по заданному разделителю с 2мя обязательными и 4мя необязательными параметрами.<br />
Функция возвращает <font color="Blue">True</font>, если строка была обрезана и <font color="blue">заменяет</font> переданную строку новой.
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Описание параметров:</div>
				   <div class="spoiler-body">
					   • <b>v</b> — строка для обрезки<br />
• <b>sep</b> — разделитель, по которому нужно обрезать (один или несколько символов)<br />
<br />
• [<b>DelRightPart</b>] — удалить правую часть от разделителя (по умолчанию — левую)<br />
• [<b>SearchFromEnd</b>] — искать разделитель с конца (по умолчанию — с начала)<br />
• [<b>CaseIgnore</b>] — игнорировать регистр (по умолчанию — учитывает)<br />
• [<b>SaveSep</b>] — сохранить разделитель (по умолчанию — удаляет вместе с ним)
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Код. Функция и тест</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="696388738"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="696388738" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> DelBySep(v, <span class="kw4">ByVal</span> sep$, <span class="kw4">Optional</span> <span class="kw4">ByVal</span> DelRightPart <span class="kw4">As</span> <span class="kw1">Boolean</span>, <span class="kw4">Optional</span> <span class="kw4">ByVal</span> SearchFromEnd <span class="kw4">As</span> <span class="kw1">Boolean</span>, <span class="kw4">Optional</span> <span class="kw4">ByVal</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>, <span class="kw4">Optional</span> <span class="kw4">ByVal</span> SaveSep <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Boolean</span>
<span class="kw4">Dim</span> res$, i&amp;, l&amp;, lSave&amp;
&nbsp;
res = v
&nbsp;
<span class="kw3">Select</span> <span class="kw3">Case</span> SearchFromEnd
&nbsp; &nbsp; <span class="kw3">Case</span> <span class="kw5">True</span>: i = InStrRev(res, sep, , Abs(CaseIgnore))
&nbsp; &nbsp; <span class="kw3">Case</span> <span class="kw3">Else</span>: i = InStr(1, res, sep, Abs(CaseIgnore))
<span class="kw3">End</span> <span class="kw3">Select</span>
&nbsp;
<span class="kw3">If</span> i = 0 <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
l = Len(sep): <span class="kw3">If</span> SaveSep <span class="kw3">Then</span> lSave = l
&nbsp;
<span class="kw3">Select</span> <span class="kw3">Case</span> DelRightPart
&nbsp; &nbsp; <span class="kw3">Case</span> <span class="kw5">True</span>: res = Left$(res, i + lSave - 1)
&nbsp; &nbsp; <span class="kw3">Case</span> <span class="kw3">Else</span>: res = Mid$(res, (i + l) - lSave)
<span class="kw3">End</span> <span class="kw3">Select</span>
&nbsp;
<span class="kw3">If</span> res &lt;&gt; CStr(v) <span class="kw3">Then</span> v = res: DelBySep = <span class="kw5">True</span>
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Private</span> <span class="kw2">Sub</span> Test()
<span class="kw4">Dim</span> a(4) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> x, tx$, res$, n&amp;, s&amp;
Const sep$ = <span class="st0">&quot;y&quot;</span>
&nbsp;
tx = <span class="st0">&quot;1Y2y3Y4y&quot;</span>
&nbsp;
<span class="kw3">For</span> <span class="kw3">Each</span> x <span class="kw3">In</span> Array(<span class="st0">&quot;0000&quot;</span>, <span class="st0">&quot;0001&quot;</span>, <span class="st0">&quot;0010&quot;</span>, <span class="st0">&quot;0011&quot;</span>, <span class="st0">&quot;0100&quot;</span>, <span class="st0">&quot;0101&quot;</span>, <span class="st0">&quot;0110&quot;</span>, <span class="st0">&quot;0111&quot;</span>, <span class="st0">&quot;1000&quot;</span>, <span class="st0">&quot;1001&quot;</span>, <span class="st0">&quot;1010&quot;</span>, <span class="st0">&quot;1011&quot;</span>, <span class="st0">&quot;1100&quot;</span>, <span class="st0">&quot;1101&quot;</span>, <span class="st0">&quot;1110&quot;</span>, <span class="st0">&quot;1111&quot;</span>)
&nbsp; &nbsp; <span class="kw3">For</span> s = 1 <span class="kw3">To</span> 4
&nbsp; &nbsp; &nbsp; &nbsp; a(s) = Mid$(x, s, 1)
&nbsp; &nbsp; <span class="kw3">Next</span> s
&nbsp;
&nbsp; &nbsp; n = n + 1: res = tx
&nbsp; &nbsp; Debug.<span class="kw4">Print</span> n, x, DelBySep(res, sep, a(1), a(2), a(3), a(4)), res, Len(res)
<span class="kw3">Next</span> x
&nbsp;
<span class="kw3">End</span> <span class="kw2">Sub</span></pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Скрин окна «Immediate» из теста</div>
				   <div class="spoiler-body">
					   <a href="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7874&amp;d=1673446200" rel="Lightbox" id="attachment7874" ><img src="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7874&amp;thumb=1&amp;d=1673446200" class="thumbnail" border="0" alt="Нажмите на изображение для увеличения
Название: Снимок.PNG
Просмотров: 308
Размер:	9.9 Кб
ID:	7874" style="margin: 5px" /></a>
				   </div>
			   </div></div>

]]></content:encoded>
			<dc:creator>Jack Famous</dc:creator>
			<guid isPermaLink="true">https://www.cyberforum.ru/blogs/1808109/7892.html</guid>
		</item>
		<item>
			<title>Замена слов / Word Replace</title>
			<link>https://www.cyberforum.ru/blogs/1808109/7879.html</link>
			<pubDate>Fri, 30 Dec 2022 12:19:56 GMT</pubDate>
			<description>*Приветствую!* 
Решил выложить свои (и не только) решения по осуществлению задачи по замене слов в...</description>
			<content:encoded><![CDATA[<div><b>Приветствую!</b><br />
Решил выложить свои (и не только) решения по осуществлению задачи по замене слов в строке.<br />
Вопрос был поднят на <b>Планете Excel</b>[<i>ссылка удалена администратором</i>], откуда я и взял <b>шаблон</b>[<i>ссылка удалена администратором</i>] для регулярки, созданный Игорем Гончаренко.<br />
<br />
Начать нужно с определения того, что считать [отдельным] &quot;словом&quot;: в предложенных решениях &quot;словом&quot; считается 1 и более [идущих подряд] символов кириллицы или латиницы.<br />
<br />
<u>Предложены 2 различных подхода:</u> регулярные выражения и комплексный алгоритм на основе парсинга строки, как байтового массива. Для каждого из вариантов есть 2 версии: для замены одного &quot;слова&quot; и для замены &quot;слов&quot; по списку.<br />
<br />
Все функции оптимизированы и очень быстрые, а также имеют опцию игнорирования регистра<br />
Базовые необходимые проверки присутствуют.<br />
Регулярные функции являются булевыми, а мои — возвращают количество произведённых замен.<br />
<br />
Регулярные выражения - чрезвычайно мощный инструмент (не забываем про раннее связывание), соревноваться с которым на VBA очень тяжело. Мне удалось приблизиться к его скорости, а в некоторых тестах даже сравняться или незначительно обогнать.<br />
<br />

			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Файл</div>
				   <div class="spoiler-body">
					   <a href="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7861&amp;d=1672402783" >ReplaceWords.7z</a>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Код с замерами времени</div>
				   <div class="spoiler-body">
					   
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">«Main». Основной модуль с тестовой процедурой и функциями замены</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="22026060"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="22026060" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> TextMult(<span class="kw4">ByVal</span> v$, Mult&amp;, <span class="kw4">Optional</span> <span class="kw4">ByVal</span> Sep$ = <span class="st0">&quot; &quot;</span>) <span class="kw4">As</span> <span class="kw1">String</span>
<span class="kw4">Dim</span> tx$, n&amp;
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> Mult
&nbsp; &nbsp; tx = tx &amp; Sep &amp; v
<span class="kw3">Next</span> n
&nbsp;
TextMult = Mid$(tx, Len(Sep) + 1)
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Private</span> <span class="kw2">Sub</span> Test()
<span class="kw4">Dim</span> aFnd, aRpl
<span class="kw4">Dim</span> tx$, res$, t!, n&amp;, nR&amp;
Const nCyc&amp; = 100000, nMult&amp; = 10 &nbsp; <span class="co1">' nMult=1 Для проверки исходной строки</span>
&nbsp;
tx = <span class="st0">&quot;Вася вас не Вас,Петя:пет;не,Пет,Alexey-alex*not«Alex»&quot;</span>
aFnd = Array(<span class="st0">&quot;вас&quot;</span>, <span class="st0">&quot;пет&quot;</span>, <span class="st0">&quot;alex&quot;</span>)
aRpl = Array(<span class="st0">&quot;Василий Семёнович&quot;</span>, <span class="st0">&quot;Пётр Петрович&quot;</span>, <span class="st0">&quot;Jack&quot;</span>)
&nbsp;
<span class="co1">' Раскомментировать, если нужно проверить</span>
<span class="co1">'res = tx: Debug.Print PRDX_Text_Replace_WholeWord(res, &quot;вас&quot;, &quot;Василий Семёнович&quot;), res &nbsp; &nbsp;' 1 | Вася Василий Семёнович не Вас,Петя:пет;не,Пет,Alexey-alex*not«Alex»</span>
<span class="co1">'res = tx: Debug.Print PRDX_Text_Replace_WholeWord(res, &quot;пет&quot;, &quot;Пётр Петрович&quot;, True), res &nbsp;' 2 | Вася вас не Вас,Петя:Пётр Петрович;не,Пётр Петрович,Alexey-alex*not«Alex»</span>
<span class="co1">'res = tx: Debug.Print PRDX_Text_Replace_WholeWord_Array(res, aFnd, aRpl), res &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 3 | Вася Василий Семёнович не Вас,Петя:Пётр Петрович;не,Пет,Alexey-Jack*not«Alex»</span>
<span class="co1">'res = tx: Debug.Print PRDX_Text_Replace_WholeWord_Array(res, aFnd, aRpl, True), res &nbsp; &nbsp; &nbsp; &nbsp;' 6 | Вася Василий Семёнович не Василий Семёнович,Петя:Пётр Петрович;не,Пётр Петрович,Alexey-Jack*not«Jack»</span>
&nbsp;
<span class="co1">' Число замен рассчитано с помощью RE.Execute().Count. Считает некорректно. Убрал. Если оставить, то увеличивает время выполнения примерно в 2 раза.</span>
<span class="co1">'res = tx: Debug.Print IG_ReplaceWholeWord(res, &quot;вас&quot;, &quot;Василий Семёнович&quot;), res &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 1 | Вася Василий Семёнович не Вас,Петя:пет;не,Пет,Alexey-alex*not«Alex»</span>
<span class="co1">'res = tx: Debug.Print IG_ReplaceWholeWord(res, &quot;пет&quot;, &quot;Пётр Петрович&quot;, True), res &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 2 | Вася вас не Вас,Петя:Пётр Петрович;не,Пётр Петрович,Alexey-alex*not«Alex»</span>
<span class="co1">'res = tx: Debug.Print IG_ReplaceWholeWord_Array(res, aFnd, aRpl), res &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 1 | Вася Василий Семёнович не Вас,Петя:Пётр Петрович;не,Пет,Alexey-Jack*not«Alex»</span>
<span class="co1">'res = tx: Debug.Print IG_ReplaceWholeWord_Array(res, aFnd, aRpl, True), res &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 2 | Вася Василий Семёнович не Василий Семёнович,Петя:Пётр Петрович;не,Пётр Петрович,Alexey-Jack*not«Jack»</span>
&nbsp;
&nbsp;
tx = TextMult(tx, nMult)
&nbsp;
t = Timer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">' Исх. &nbsp;| x10</span>
 &nbsp; &nbsp;<span class="kw3">For</span> n = 1 <span class="kw3">To</span> nCyc / nMult
&nbsp; &nbsp; &nbsp; &nbsp; res = tx: nR = PRDX_Text_Replace_WholeWord_Array(res, aFnd, aRpl) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">' 2.58 | 1.78</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = tx: nR = PRDX_Text_Replace_WholeWord_Array(res, aFnd, aRpl, True) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 2.89 | 1.97</span>
&nbsp;
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = tx: nR = IG_ReplaceWholeWord_Array(res, aFnd, aRpl) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 2.64 | 1,48</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = tx: nR = IG_ReplaceWholeWord_Array(res, aFnd, aRpl, True) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 2,98 | 1.66</span>
 &nbsp; &nbsp;<span class="kw3">Next</span> n
Debug.<span class="kw4">Print</span> Format$(Timer - t, <span class="st0">&quot;0.00&quot;</span>), nR
&nbsp;
<span class="kw3">End</span> <span class="kw2">Sub</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_Text_Replace_WholeWord(tmpString, <span class="kw4">ByVal</span> iFnd$, <span class="kw4">ByVal</span> iRpl$, <span class="kw4">Optional</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> aWrd$(), aSep$()
<span class="kw4">Dim</span> n&amp;, nRpl&amp;
&nbsp;
<span class="kw3">If</span> <span class="kw3">Not</span> LCase$(tmpString) <span class="kw3">Like</span> <span class="st0">&quot;*[a-zёа-я]*&quot;</span> <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
<span class="kw3">If</span> <span class="kw3">Not</span> PRDX_SplitString_ByNonCyrLat(tmpString, aWrd, aSep) <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
&nbsp;
<span class="kw3">If</span> CaseIgnore <span class="kw3">Then</span>
&nbsp; &nbsp; iFnd = LCase$(iFnd)
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> iFnd = LCase$(aWrd(n)) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(n) = iRpl
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">Else</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> iFnd = aWrd(n) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(n) = iRpl
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">If</span> nRpl <span class="kw3">Then</span> PRDX_Text_Replace_WholeWord = nRpl <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
tmpString = PRDX_SplitString_ByNonCyrLat_Join(aWrd, aSep)
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_Text_Replace_WholeWord_Array(tmpString, aFind, aRpl, <span class="kw4">Optional</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> aWrd$(), aSep$()
<span class="kw4">Dim</span> tx$, f&amp;, n&amp;, nRpl&amp;
<span class="kw4">Static</span> st&amp;, dic <span class="kw4">As</span> Dictionary
&nbsp;
<span class="kw3">If</span> <span class="kw3">Not</span> LCase$(tmpString) <span class="kw3">Like</span> <span class="st0">&quot;*[a-zёа-я]*&quot;</span> <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
<span class="kw3">If</span> st = 0 <span class="kw3">Then</span> st = 1: <span class="kw4">Set</span> dic = <span class="kw2">New</span> Dictionary
<span class="kw3">If</span> <span class="kw3">Not</span> PRDX_SplitString_ByNonCyrLat(tmpString, aWrd, aSep) <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
&nbsp;
<span class="kw3">If</span> CaseIgnore <span class="kw3">Then</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = <span class="kw4">LBound</span>(aFind) <span class="kw3">To</span> <span class="kw4">UBound</span>(aFind)
&nbsp; &nbsp; &nbsp; &nbsp; tx = LCase$(aFind(n))
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> <span class="kw3">Not</span> dic.Exists(tx) <span class="kw3">Then</span> dic.Add tx, aRpl(n)
&nbsp; &nbsp; <span class="kw3">Next</span> n
&nbsp;
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; tx = LCase$(aWrd(n))
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> dic.Exists(tx) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(n) = dic(tx)
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">Else</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = <span class="kw4">LBound</span>(aFind) <span class="kw3">To</span> <span class="kw4">UBound</span>(aFind)
&nbsp; &nbsp; &nbsp; &nbsp; tx = aFind(n)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> <span class="kw3">Not</span> dic.Exists(tx) <span class="kw3">Then</span> dic.Add tx, aRpl(n)
&nbsp; &nbsp; <span class="kw3">Next</span> n
&nbsp;
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> dic.Exists(aWrd(n)) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(n) = dic(aWrd(n))
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
dic.RemoveAll
<span class="kw3">If</span> nRpl <span class="kw3">Then</span> PRDX_Text_Replace_WholeWord_Array = nRpl <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
tmpString = PRDX_SplitString_ByNonCyrLat_Join(aWrd, aSep)
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> IG_ReplaceWholeWord(tmpString, <span class="kw4">ByVal</span> iFnd$, <span class="kw4">ByVal</span> iRpl$, <span class="kw4">Optional</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Boolean</span>
<span class="kw4">Dim</span> x, tx$
<span class="kw4">Static</span> st&amp;, RE <span class="kw4">As</span> RegExp, REci <span class="kw4">As</span> RegExp
&nbsp;
<span class="kw3">If</span> st = 0 <span class="kw3">Then</span>
&nbsp; &nbsp; st = 1
&nbsp; &nbsp; <span class="kw4">Set</span> RE = <span class="kw2">New</span> RegExp: RE.Global = <span class="kw5">True</span>
&nbsp; &nbsp; <span class="kw4">Set</span> REci = <span class="kw2">New</span> RegExp: REci.Global = <span class="kw5">True</span>: REci.IgnoreCase = <span class="kw5">True</span>
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">If</span> CaseIgnore <span class="kw3">Then</span>
&nbsp; &nbsp; tx = <span class="st0">&quot;(^|[^a-zа-яё])&quot;</span> &amp; iFnd &amp; <span class="st0">&quot;(?=[^a-zа-яё]|$)&quot;</span>
&nbsp; &nbsp; <span class="kw3">If</span> REci.Pattern &lt;&gt; tx <span class="kw3">Then</span> REci.Pattern = tx
&nbsp;
&nbsp; &nbsp; <span class="kw3">If</span> REci.Test(tmpString) <span class="kw3">Then</span> IG_ReplaceWholeWord = <span class="kw5">True</span> <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp; &nbsp; tmpString = REci.Replace(tmpString, <span class="st0">&quot;$1&quot;</span> &amp; iRpl)
<span class="kw3">Else</span>
&nbsp; &nbsp; tx = <span class="st0">&quot;(^|[^A-Za-zА-яЁё])&quot;</span> &amp; iFnd &amp; <span class="st0">&quot;(?=[^A-Za-zА-яЁё]|$)&quot;</span>
&nbsp; &nbsp; <span class="kw3">If</span> RE.Pattern &lt;&gt; tx <span class="kw3">Then</span> RE.Pattern = tx
&nbsp;
&nbsp; &nbsp; <span class="kw3">If</span> RE.Test(tmpString) <span class="kw3">Then</span> IG_ReplaceWholeWord = <span class="kw5">True</span> <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp; &nbsp; tmpString = RE.Replace(tmpString, <span class="st0">&quot;$1&quot;</span> &amp; iRpl)
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> IG_ReplaceWholeWord_Array(tmpString, aFind, aRpl, <span class="kw4">Optional</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Boolean</span>
<span class="kw4">Dim</span> x, n&amp;
<span class="kw4">Static</span> st&amp;, RE <span class="kw4">As</span> RegExp, REci <span class="kw4">As</span> RegExp
&nbsp;
<span class="kw3">If</span> st = 0 <span class="kw3">Then</span>
&nbsp; &nbsp; st = 1
&nbsp; &nbsp; <span class="kw4">Set</span> RE = <span class="kw2">New</span> RegExp: RE.Global = <span class="kw5">True</span>
&nbsp; &nbsp; <span class="kw4">Set</span> REci = <span class="kw2">New</span> RegExp: REci.Global = <span class="kw5">True</span>: REci.IgnoreCase = <span class="kw5">True</span>
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">If</span> CaseIgnore <span class="kw3">Then</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = <span class="kw4">LBound</span>(aFind) <span class="kw3">To</span> <span class="kw4">UBound</span>(aFind)
&nbsp; &nbsp; &nbsp; &nbsp; REci.Pattern = <span class="st0">&quot;(^|[^a-zа-яё])&quot;</span> &amp; aFind(n) &amp; <span class="st0">&quot;(?=[^a-zа-яё]|$)&quot;</span>
&nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> REci.Test(tmpString) <span class="kw3">Then</span> IG_ReplaceWholeWord_Array = <span class="kw5">True</span> <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp; &nbsp; &nbsp; &nbsp; tmpString = REci.Replace(tmpString, <span class="st0">&quot;$1&quot;</span> &amp; aRpl(n))
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">Else</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = <span class="kw4">LBound</span>(aFind) <span class="kw3">To</span> <span class="kw4">UBound</span>(aFind)
&nbsp; &nbsp; &nbsp; &nbsp; RE.Pattern = <span class="st0">&quot;(^|[^A-Za-zА-яЁё])&quot;</span> &amp; aFind(n) &amp; <span class="st0">&quot;(?=[^A-Za-zА-яЁё]|$)&quot;</span>
&nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> RE.Test(tmpString) <span class="kw3">Then</span> IG_ReplaceWholeWord_Array = <span class="kw5">True</span> <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp; &nbsp; &nbsp; &nbsp; tmpString = RE.Replace(tmpString, <span class="st0">&quot;$1&quot;</span> &amp; aRpl(n))
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">End</span> <span class="kw3">If</span>
<span class="kw3">End</span> <span class="kw2">Function</span></pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Модуль «AscW_Check». Функция определения принадлежности символа по его коду AscW к кириллице или латинице</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="558924529"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="558924529" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="co1">' Num: 48-57</span>
<span class="co1">' Lat: 65-90; 97-122</span>
<span class="co1">' Cyr: 1025; 1040-1103; 1105</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_AscW_CyrAndLat_GetArr() <span class="kw4">As</span> <span class="kw1">Long</span>()
<span class="kw4">Dim</span> a&amp;(1105), s&amp;
&nbsp;
<span class="kw3">For</span> s = 65 <span class="kw3">To</span> 1105
&nbsp; &nbsp; <span class="kw3">Select</span> <span class="kw3">Case</span> s
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Case</span> 91: &nbsp; &nbsp;s = 97
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Case</span> 123: &nbsp; s = 1025
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Case</span> 1026: &nbsp;s = 1040
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Case</span> 1104: &nbsp;s = 1105
&nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">Select</span>
&nbsp; &nbsp; a(s) = 1
<span class="kw3">Next</span> s
&nbsp;
PRDX_AscW_CyrAndLat_GetArr = a
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_AscW_CyrAndLat_Is(iAscW&amp;) <span class="kw4">As</span> <span class="kw1">Boolean</span>
<span class="kw4">Static</span> st&amp;, a&amp;()
&nbsp; &nbsp; <span class="kw3">If</span> iAscW &gt; 1105 <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp; &nbsp; <span class="kw3">If</span> st = 0 <span class="kw3">Then</span> st = 1: a = PRDX_AscW_CyrAndLat_GetArr()
&nbsp; &nbsp; <span class="kw3">If</span> a(iAscW) <span class="kw3">Then</span> PRDX_AscW_CyrAndLat_Is = <span class="kw5">True</span>
<span class="kw3">End</span> <span class="kw2">Function</span></pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Модуль «Splitter». Получение из строки 2ух массивов: слова и неслова</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="66086396"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="66086396" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="kw2">Private</span> <span class="kw2">Sub</span> Test_PRDX_SplitString_ByNonCyrLat()
<span class="kw4">Dim</span> x, w$(), s$(), n&amp;
&nbsp;
x = <span class="st0">&quot;,./asd.gh./*красота/*b./7jg,,./&quot;</span>
<span class="kw3">If</span> <span class="kw3">Not</span> PRDX_SplitString_ByNonCyrLat(x, w, s) <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Sub</span>
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(s)
&nbsp; &nbsp; Debug.<span class="kw4">Print</span> <span class="st0">&quot;«&quot;</span> &amp; s(n) &amp; <span class="st0">&quot;»&quot;</span>
&nbsp; &nbsp; <span class="kw3">If</span> n &lt; <span class="kw4">UBound</span>(s) <span class="kw3">Then</span> Debug.<span class="kw4">Print</span> <span class="st0">&quot;«&quot;</span> &amp; w(n) &amp; <span class="st0">&quot;»&quot;</span>
<span class="kw3">Next</span> n
&nbsp;
Debug.<span class="kw4">Print</span> x = PRDX_SplitString_ByNonCyrLat_Join(w, s)
<span class="kw3">End</span> <span class="kw2">Sub</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">' Fill aWrd(N) and aSep(N+1)</span>
<span class="kw2">Function</span> PRDX_SplitString_ByNonCyrLat(<span class="kw4">ByVal</span> iStr$, aWrd$(), aSep$()) <span class="kw4">As</span> <span class="kw1">Boolean</span>
<span class="kw4">Dim</span> aBt() <span class="kw4">As</span> <span class="kw1">Byte</span>
<span class="kw4">Dim</span> i&amp;, n&amp;, nW&amp;, nS&amp;, bW&amp;, bS&amp;
&nbsp;
aBt = iStr
<span class="kw4">ReDim</span> aWrd(Len(iStr))
<span class="kw4">ReDim</span> aSep(<span class="kw4">UBound</span>(aWrd))
&nbsp;
<span class="kw3">For</span> i = 0 <span class="kw3">To</span> <span class="kw4">UBound</span>(aBt) <span class="kw3">Step</span> 2
&nbsp; &nbsp; n = n + 1
&nbsp;
&nbsp; &nbsp; <span class="kw3">If</span> PRDX_AscW_CyrAndLat_Is(aBt(i) + 256 * aBt(i + 1)) <span class="kw3">Then</span> &nbsp; <span class="co1">' Ltr</span>
 &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">If</span> bW <span class="kw3">Then</span> <span class="kw3">GoTo</span> nx <span class="kw3">Else</span> bW = n
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> bS = 0 <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> nS = 0 <span class="kw3">Then</span> nS = nS + 1: aSep(nS) = <span class="st0">&quot;&quot;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">GoTo</span> nx
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; nS = nS + 1: aSep(nS) = Mid$(iStr, bS, n - bS): bS = 0
&nbsp; &nbsp; <span class="kw3">Else</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">' NonLtr</span>
 &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">If</span> bS <span class="kw3">Then</span> <span class="kw3">GoTo</span> nx <span class="kw3">Else</span> bS = n
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> bW = 0 <span class="kw3">Then</span> <span class="kw3">GoTo</span> nx
&nbsp; &nbsp; &nbsp; &nbsp; nW = nW + 1: aWrd(nW) = Mid$(iStr, bW, n - bW): bW = 0
&nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
nx:
<span class="kw3">Next</span> i
&nbsp;
<span class="kw3">If</span> bW <span class="kw3">Then</span>
&nbsp; &nbsp; nW = nW + 1: aWrd(nW) = Mid$(iStr, bW)
<span class="kw3">Else</span>
&nbsp; &nbsp; nS = nS + 1: aSep(nS) = Mid$(iStr, bS)
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">If</span> nW = 0 <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
<span class="kw3">If</span> nS &lt; nW <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
<span class="kw3">If</span> nS &gt; nW + 1 <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
<span class="kw3">If</span> nS = nW <span class="kw3">Then</span> nS = nS + 1: aSep(nS) = <span class="st0">&quot;&quot;</span>
&nbsp;
<span class="kw4">ReDim</span> <span class="kw4">Preserve</span> aWrd(nW)
<span class="kw4">ReDim</span> <span class="kw4">Preserve</span> aSep(nS)
PRDX_SplitString_ByNonCyrLat = <span class="kw5">True</span>
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_SplitString_ByNonCyrLat_Join(aWrd$(), aSep$()) <span class="kw4">As</span> <span class="kw1">String</span>
<span class="kw4">Dim</span> tx$, n&amp;
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; tx = tx &amp; aSep(n) &amp; aWrd(n)
<span class="kw3">Next</span> n
&nbsp;
PRDX_SplitString_ByNonCyrLat_Join = tx &amp; aSep(<span class="kw4">UBound</span>(aSep))
<span class="kw3">End</span> <span class="kw2">Function</span>
'==================================================================================================</pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Алгоритм НЕрегулярного варианта</div>
				   <div class="spoiler-body">
					   <br />
1. Берём строку в байтовый массив.<br />
2. В цикле по байтам определяем принадлежность очередного символа к кириллице или латинице.<br />
3. Собираем 2 массива (&quot;слов&quot; и &quot;неслов&quot;) в порядке их расположения в строке. Массив НЕслов ВСЕГДА на 1 больше, чем массив слов. Сделано это для однозначности - отдельная функция сцепляет эти массивы обратно в строку, беря 1ый элемент массива &quot;НЕслов&quot;, прибавляя к нему 1ый элемент массива &quot;слов&quot; и так далее, пока массив &quot;слов&quot; не кончится. В конце добавляем гарантированно оставшийся элемент массива &quot;НЕслов&quot;. Если строка начинается/заканчивается с символа &quot;НЕслова&quot;, то будут они, если первым/последним символом является &quot;слово&quot;, то в массиве &quot;НЕслов&quot; будут строки нолевой длины &quot;&quot;.<br />
4. Функции замены остаётся только пробежаться по массиву &quot;слов&quot;, произвести замены и сцепить 2 массива обратно в строку
				   </div>
			   </div><br />
<br />

			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">UPD 2023/01/09: Обновление. Выше не правил.</div>
				   <div class="spoiler-body">
					   <br />
• Обновил старую функцию (~ 15%), добавив проверку длины первого и последнего разделителя.<br />
• Сделал новую функцию сцепки массивов &quot;слов-неслов&quot; обратно в строку (быстрее обновлённой старой на ~30%).<br />
• Сделал функцию сцепки с помощью Join'а (~ 2x медленнее новой).<br />
• Сделал процедуру сравнения всех этих 3ёх вариантов.<br />
<br />
<b>Важно:</b><br />
• для работы новой функции нужна длина новой строки (чем длиннее строка, тем больше будет выигрыш).<br />
• если встроить [а не вызывать отдельно] сбор строки старым методом &quot;в лоб&quot; в функцию замены слов [в цикл замены], то может быть быстрее, чем собирать длину строки и запускать новую функцию отдельно.
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Код</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="764410754"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="764410754" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_SplitString_ByNonCyrLat_Join(aWrd$(), aSep$(), iLen&amp;) <span class="kw4">As</span> <span class="kw1">String</span>
<span class="kw4">Dim</span> tx$, n&amp;, p&amp;, l&amp;
&nbsp;
tx = <span class="kw1">String</span>$(iLen, <span class="st0">&quot; &quot;</span>): p = 1
&nbsp;
l = Len(aSep(1))
<span class="kw3">If</span> l <span class="kw3">Then</span> Mid$(tx, p, l) = aSep(1): &nbsp; &nbsp; &nbsp; &nbsp; p = p + l
l = Len(aWrd(1)): Mid$(tx, p, l) = aWrd(1): p = p + l
&nbsp;
<span class="kw3">For</span> n = 2 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; l = Len(aSep(n)): Mid$(tx, p, l) = aSep(n): p = p + l
&nbsp; &nbsp; l = Len(aWrd(n)): Mid$(tx, p, l) = aWrd(n): p = p + l
<span class="kw3">Next</span> n
&nbsp;
l = Len(aSep(n))
<span class="kw3">If</span> l <span class="kw3">Then</span> Mid$(tx, p, l) = aSep(n)
&nbsp;
PRDX_SplitString_ByNonCyrLat_Join = tx
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'--------------------------------------------------------------------------------------------------</span>
<span class="kw2">Function</span> PRDX_SplitString_ByNonCyrLat_Join2(aWrd$(), aSep$()) <span class="kw4">As</span> <span class="kw1">String</span>
<span class="kw4">Dim</span> tx$, n&amp;
&nbsp;
<span class="kw3">If</span> Len(aSep(1)) <span class="kw3">Then</span>
&nbsp; &nbsp; tx = aSep(1) &amp; aWrd(1)
<span class="kw3">Else</span>
&nbsp; &nbsp; tx = aWrd(1)
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">For</span> n = 2 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; tx = tx &amp; aSep(n) &amp; aWrd(n)
<span class="kw3">Next</span> n
&nbsp;
<span class="kw3">If</span> Len(aSep(n)) <span class="kw3">Then</span>
&nbsp; &nbsp; PRDX_SplitString_ByNonCyrLat_Join2 = tx &amp; aSep(n)
<span class="kw3">Else</span>
&nbsp; &nbsp; PRDX_SplitString_ByNonCyrLat_Join2 = tx
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'--------------------------------------------------------------------------------------------------</span>
<span class="kw2">Function</span> PRDX_SplitString_ByNonCyrLat_Join3(aWrd$(), aSep$()) <span class="kw4">As</span> <span class="kw1">String</span>
<span class="kw4">Dim</span> a$(), tx$, n&amp;, j&amp;
&nbsp;
n = <span class="kw4">UBound</span>(aWrd) + <span class="kw4">UBound</span>(aSep)
&nbsp;
<span class="kw3">If</span> Len(aSep(1)) <span class="kw3">Then</span>
&nbsp; &nbsp; <span class="kw3">If</span> Len(aSep(<span class="kw4">UBound</span>(aSep))) <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">ReDim</span> a(n)
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = j + 1: a(j) = aSep(n)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = j + 1: a(j) = aWrd(n)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Next</span> n
&nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; j = j + 1: a(j) = aSep(n)
&nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">ReDim</span> a(n - 1)
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = j + 1: a(j) = aSep(n)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = j + 1: a(j) = aWrd(n)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Next</span> n
&nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
<span class="kw3">Else</span>
&nbsp; &nbsp; <span class="kw3">If</span> Len(aSep(<span class="kw4">UBound</span>(aSep))) <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">ReDim</span> a(n - 1)
&nbsp; &nbsp; &nbsp; &nbsp; j = j + 1: a(j) = aWrd(1)
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">For</span> n = 2 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = j + 1: a(j) = aSep(n)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = j + 1: a(j) = aWrd(n)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Next</span> n
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; j = j + 1: a(j) = aSep(n)
&nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">ReDim</span> a(n - 2)
&nbsp; &nbsp; &nbsp; &nbsp; j = j + 1: a(j) = aWrd(1)
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">For</span> n = 2 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = j + 1: a(j) = aSep(n)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = j + 1: a(j) = aWrd(n)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Next</span> n
&nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
PRDX_SplitString_ByNonCyrLat_Join3 = Join(a, <span class="st0">&quot;&quot;</span>)
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Private</span> <span class="kw2">Sub</span> Test_PRDX_SplitString_ByNonCyrLat_Join()
<span class="kw4">Dim</span> tx$, w$(), s$()
<span class="kw4">Dim</span> res$, t!, n&amp;, l&amp;
&nbsp;
tx = <span class="st0">&quot;asd.gh7jg.sdfsddf.234sfd.sdfs sdfsdfjjkl&quot;</span>
tx = <span class="st0">&quot;.&quot;</span> &amp; tx &amp; <span class="st0">&quot;.&quot;</span> <span class="co1">' UnComment for .*.</span>
l = Len(tx)
<span class="kw3">If</span> <span class="kw3">Not</span> PRDX_SplitString_ByNonCyrLat(tx, w, s) <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Sub</span>
&nbsp;
t = Timer
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> 1000000 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">' &nbsp;* &nbsp; &nbsp;/ .*.</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = PRDX_SplitString_ByNonCyrLat_Join(w, s, l) &nbsp; ' 0.72 &nbsp;/ 0.77</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = PRDX_SplitString_ByNonCyrLat_Join2(w, s) &nbsp; &nbsp; ' 0.96 &nbsp;/ 1.02</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = PRDX_SplitString_ByNonCyrLat_Join3(w, s) &nbsp; &nbsp; ' 1.71 &nbsp;/ 1.95</span>
 &nbsp; &nbsp;<span class="kw3">Next</span> n
Debug.<span class="kw4">Print</span> Format$(Timer - t, <span class="st0">&quot;0.00&quot;</span>), res = tx, <span class="st0">&quot;«&quot;</span> &amp; res &amp; <span class="st0">&quot;»&quot;</span>
<span class="kw3">End</span> <span class="kw2">Sub</span></pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Продолжение. Тесты показали, что встраивать в цикл смысла нет, а вот новая функция заметно ускоряет весь процесс</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="478617669"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="478617669" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Private</span> <span class="kw2">Sub</span> Test()
<span class="kw4">Dim</span> tx$, res$, t!, n&amp;, nR&amp;
Const nCyc&amp; = 100000, nMult&amp; = 10 &nbsp; <span class="co1">' nMult=1 Для проверки исходной строки</span>
&nbsp;
tx = <span class="st0">&quot;Вася вас не Вас,Петя:пет;не,Пет,Alexey-alex*not«Alex»&quot;</span>
&nbsp;
<span class="co1">' Раскомментировать, если нужно проверить</span>
<span class="co1">'res = tx: Debug.Print PRDX_Text_Replace_WholeWord(res, &quot;вас&quot;, &quot;Василий Семёнович&quot;), res &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 1 | Вася Василий Семёнович не Вас,Петя:пет;не,Пет,Alexey-alex*not«Alex»</span>
<span class="co1">'res = tx: Debug.Print PRDX_Text_Replace_WholeWord(res, &quot;пет&quot;, &quot;Пётр Петрович&quot;, True), res &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 2 | Вася вас не Вас,Петя:Пётр Петрович;не,Пётр Петрович,Alexey-alex*not«Alex»</span>
&nbsp;
<span class="co1">'res = tx: Debug.Print PRDX_Text_Replace_WholeWord_OneCycle(res, &quot;вас&quot;, &quot;Василий Семёнович&quot;), res &nbsp; ' 1 | Вася Василий Семёнович не Вас,Петя:пет;не,Пет,Alexey-alex*not«Alex»</span>
<span class="co1">'res = tx: Debug.Print PRDX_Text_Replace_WholeWord_OneCycle(res, &quot;пет&quot;, &quot;Пётр Петрович&quot;, True), res ' 2 | Вася вас не Вас,Петя:Пётр Петрович;не,Пётр Петрович,Alexey-alex*not«Alex»</span>
&nbsp;
<span class="co1">'res = tx: Debug.Print PRDX_Text_Replace_WholeWord_Mid(res, &quot;вас&quot;, &quot;Василий Семёнович&quot;), res &nbsp; &nbsp; &nbsp; &nbsp;' 1 | Вася Василий Семёнович не Вас,Петя:пет;не,Пет,Alexey-alex*not«Alex»</span>
<span class="co1">'res = tx: Debug.Print PRDX_Text_Replace_WholeWord_Mid(res, &quot;пет&quot;, &quot;Пётр Петрович&quot;, True), res &nbsp; &nbsp; &nbsp;' 2 | Вася вас не Вас,Петя:Пётр Петрович;не,Пётр Петрович,Alexey-alex*not«Alex»</span>
&nbsp;
tx = PRDX_Text_Mult(tx, nMult)
&nbsp;
t = Timer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">' Исх. | x10</span>
 &nbsp; &nbsp;<span class="kw3">For</span> n = 1 <span class="kw3">To</span> nCyc / nMult
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = tx: nR = PRDX_Text_Replace_WholeWord(res, &quot;вас&quot;, &quot;Василий Семёнович&quot;) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 1.72 | 1.64</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = tx: nR = PRDX_Text_Replace_WholeWord_OneCycle(res, &quot;вас&quot;, &quot;Василий Семёнович&quot;) &nbsp; &nbsp; &nbsp; ' 1.72 | 1.67</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = tx: nR = PRDX_Text_Replace_WholeWord_Mid(res, &quot;вас&quot;, &quot;Василий Семёнович&quot;) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 1.69 | 1.53</span>
 &nbsp; &nbsp;<span class="kw3">Next</span> n
Debug.<span class="kw4">Print</span> Format$(Timer - t, <span class="st0">&quot;0.00&quot;</span>), nR
&nbsp;
<span class="kw3">End</span> <span class="kw2">Sub</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_Text_Replace_WholeWord(tmpString, <span class="kw4">ByVal</span> iFnd$, <span class="kw4">ByVal</span> iRpl$, <span class="kw4">Optional</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> aWrd$(), aSep$()
<span class="kw4">Dim</span> n&amp;, nRpl&amp;
&nbsp;
<span class="kw3">If</span> <span class="kw3">Not</span> PRDX_SplitString_ByNonCyrLat(tmpString, aWrd, aSep) <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
&nbsp;
<span class="kw3">If</span> CaseIgnore <span class="kw3">Then</span>
&nbsp; &nbsp; iFnd = LCase$(iFnd)
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> iFnd = LCase$(aWrd(n)) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(n) = iRpl
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">Else</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> iFnd = aWrd(n) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(n) = iRpl
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">If</span> nRpl <span class="kw3">Then</span> PRDX_Text_Replace_WholeWord = nRpl <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
tmpString = PRDX_SplitString_ByNonCyrLat_Join2(aWrd, aSep)
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'--------------------------------------------------------------------------------------------------</span>
<span class="kw2">Function</span> PRDX_Text_Replace_WholeWord_OneCycle(tmpString, <span class="kw4">ByVal</span> iFnd$, <span class="kw4">ByVal</span> iRpl$, <span class="kw4">Optional</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> aWrd$(), aSep$()
<span class="kw4">Dim</span> res$, n&amp;, nRpl&amp;
&nbsp;
<span class="kw3">If</span> <span class="kw3">Not</span> PRDX_SplitString_ByNonCyrLat(tmpString, aWrd, aSep) <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
&nbsp;
<span class="kw3">If</span> CaseIgnore <span class="kw3">Then</span>
&nbsp; &nbsp; iFnd = LCase$(iFnd)
&nbsp;
&nbsp; &nbsp; <span class="kw3">If</span> iFnd = LCase$(aWrd(1)) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(1) = iRpl
&nbsp; &nbsp; <span class="kw3">If</span> Len(aSep(1)) <span class="kw3">Then</span> res = aSep(1) &amp; aWrd(1) <span class="kw3">Else</span> res = aWrd(1)
&nbsp;
&nbsp; &nbsp; <span class="kw3">For</span> n = 2 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> iFnd = LCase$(aWrd(n)) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(n) = iRpl
&nbsp; &nbsp; &nbsp; &nbsp; res = res &amp; aSep(n) &amp; aWrd(n)
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">Else</span>
&nbsp;
&nbsp; &nbsp; <span class="kw3">If</span> iFnd = aWrd(1) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(1) = iRpl
&nbsp; &nbsp; <span class="kw3">If</span> Len(aSep(1)) <span class="kw3">Then</span> res = aSep(1) &amp; aWrd(1) <span class="kw3">Else</span> res = aWrd(1)
&nbsp;
&nbsp; &nbsp; <span class="kw3">For</span> n = 2 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> iFnd = aWrd(n) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(n) = iRpl
&nbsp; &nbsp; &nbsp; &nbsp; res = res &amp; aSep(n) &amp; aWrd(n)
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">If</span> nRpl <span class="kw3">Then</span> PRDX_Text_Replace_WholeWord_OneCycle = nRpl <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
<span class="kw3">If</span> Len(aSep(n)) <span class="kw3">Then</span> tmpString = res &amp; aSep(n) <span class="kw3">Else</span> tmpString = res
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'--------------------------------------------------------------------------------------------------</span>
<span class="kw2">Function</span> PRDX_Text_Replace_WholeWord_Mid(tmpString, <span class="kw4">ByVal</span> iFnd$, <span class="kw4">ByVal</span> iRpl$, <span class="kw4">Optional</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> aWrd$(), aSep$()
<span class="kw4">Dim</span> n&amp;, nRpl&amp;, l&amp;
&nbsp;
<span class="kw3">If</span> <span class="kw3">Not</span> PRDX_SplitString_ByNonCyrLat(tmpString, aWrd, aSep) <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
&nbsp;
<span class="kw3">If</span> CaseIgnore <span class="kw3">Then</span>
&nbsp; &nbsp; iFnd = LCase$(iFnd)
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> iFnd = LCase$(aWrd(n)) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(n) = iRpl
&nbsp; &nbsp; &nbsp; &nbsp; l = l + Len(aSep(n)) + Len(aWrd(n))
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">Else</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> iFnd = aWrd(n) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(n) = iRpl
&nbsp; &nbsp; &nbsp; &nbsp; l = l + Len(aSep(n)) + Len(aWrd(n))
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">If</span> nRpl <span class="kw3">Then</span> PRDX_Text_Replace_WholeWord_Mid = nRpl <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
l = l + Len(aSep(n)): tmpString = PRDX_SplitString_ByNonCyrLat_Join(aWrd, aSep, l)
<span class="kw3">End</span> <span class="kw2">Function</span></pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div><br />
<br />

			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">UPD 2023/01/10: Идея ускорения. Тест сцепок.</div>
				   <div class="spoiler-body">
					   Есть идея вместо 2ух массивов делать один. Тест штатной сцепки одного стрингнового массива Join'ом показывает, что он кратно выигрывает у самого быстрого метода сцепки 2ух массивов. При условии, что все массивы определены и наполнены ПЕРЕД циклом проверки сцепки.<br />
<br />
Это означает, что идея имеет реальный смысл, если скорость получения ОДНОГО массива не будет ниже скорости получения 2ух (а этого и не случится - даже наоборот). Бонусом будет то, что не будет необходимости иметь массив НЕслов всегда больше на 1, чем массив слов (обрамляющий массив), а значит, скорость [на 2ух этапах: разбивка в массив и склейка обратно] будет ещё выше. Продолжаю.<div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="755795572"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="755795572" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_SplitString_ByNonCyrLat_Join(aWrd$(), aSep$(), iLen&amp;) <span class="kw4">As</span> <span class="kw1">String</span>
<span class="kw4">Dim</span> tx$, n&amp;, p&amp;, l&amp;
&nbsp;
tx = <span class="kw1">String</span>$(iLen, <span class="st0">&quot; &quot;</span>): p = 1
&nbsp;
l = Len(aSep(1))
<span class="kw3">If</span> l <span class="kw3">Then</span> Mid$(tx, p, l) = aSep(1): &nbsp; &nbsp; &nbsp; &nbsp; p = p + l
l = Len(aWrd(1)): Mid$(tx, p, l) = aWrd(1): p = p + l
&nbsp;
<span class="kw3">For</span> n = 2 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; l = Len(aSep(n)): Mid$(tx, p, l) = aSep(n): p = p + l
&nbsp; &nbsp; l = Len(aWrd(n)): Mid$(tx, p, l) = aWrd(n): p = p + l
<span class="kw3">Next</span> n
&nbsp;
l = Len(aSep(n))
<span class="kw3">If</span> l <span class="kw3">Then</span> Mid$(tx, p, l) = aSep(n)
&nbsp;
PRDX_SplitString_ByNonCyrLat_Join = tx
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Private</span> <span class="kw2">Sub</span> TestJoin()
<span class="kw4">Dim</span> x, a$(3), aSep$(), aWrd$(), aFull$()
<span class="kw4">Dim</span> tx$, res$, t!, n&amp;, j&amp;
&nbsp;
a(1) = <span class="st0">&quot;мама&quot;</span>
a(2) = <span class="st0">&quot;мама мыла Милу с мылом&quot;</span>
a(3) = a(2) &amp; <span class="st0">&quot;•&quot;</span> &amp; a(2) &amp; <span class="st0">&quot;•&quot;</span> &amp; a(2) &amp; <span class="st0">&quot;•&quot;</span> &amp; a(2) &amp; <span class="st0">&quot;•&quot;</span> &amp; a(2)
&nbsp;
tx = a(2)
<span class="kw3">If</span> <span class="kw3">Not</span> PRDX_SplitString_ByNonCyrLat(tx, aWrd, aSep) <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
<span class="kw4">ReDim</span> aFull(<span class="kw4">UBound</span>(aWrd) + <span class="kw4">UBound</span>(aSep))
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; j = j + 1: aFull(j) = aSep(n)
&nbsp; &nbsp; j = j + 1: aFull(j) = aWrd(n)
<span class="kw3">Next</span> n
j = j + 1: aFull(j) = aSep(n)
&nbsp;
t = Timer
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> 1000000 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">' 1 &nbsp; &nbsp; &nbsp;2 &nbsp; &nbsp; &nbsp;3</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = PRDX_SplitString_ByNonCyrLat_Join(aWrd, aSep, Len(tx)) &nbsp; &nbsp;' 0.32 | 0.61 | 1.91</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = Join(aFull, &quot;&quot;) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' 0.15 | 0.22 | 0.61</span>
 &nbsp; &nbsp;<span class="kw3">Next</span> n
Debug.<span class="kw4">Print</span> Format$(Timer - t, <span class="st0">&quot;0.00&quot;</span>), tx = res
&nbsp;
<span class="kw3">End</span> <span class="kw2">Sub</span></pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Продолжение. Тест массивов для индикации брать/не брать [очередной элемент]</div>
				   <div class="spoiler-body">
					   Несмотря на то, что <b>переменная</b> <font color="blue">Long</font>(4 байта) незначительно, но быстрее <font color="blue">Boolean</font>(2 байта) и <font color="blue">Byte</font>(1 байт) — в плане определения очередного <b>элемента массива</b> на <b><i>да/нет</i></b>, <b><i>0/1</i></b>, <b><i>False/True</i></b> <b><font color="SeaGreen">побеждает булевый</font></b> массив. <font color="blue">Integer</font> даже не рассматривал (и не использую) - он ещё на тестах переменных проиграл <font color="blue">Long</font>'у.<br />
<br />
<u>Бонус тест:</u> определение <font color="blue">Long</font> и <font color="blue">Byte</font> элемента, как <font color="blue">If a(n)=1 Then</font> или <font color="blue">If a(n)&lt;&gt;0 Then</font> немного быстрее короткой записи <font color="blue">If a(n) Then</font>, а с <font color="blue">Boolean</font> всё с точностью, но наоборот. :)<div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="87644317"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="87644317" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="kw2">Private</span> <span class="kw2">Sub</span> TestArr()
<span class="kw4">Dim</span> aLn() <span class="kw4">As</span> <span class="kw1">Long</span>, aBl() <span class="kw4">As</span> <span class="kw1">Boolean</span>, aBt() <span class="kw4">As</span> <span class="kw1">Byte</span>
<span class="kw4">Dim</span> t!, n&amp;, e&amp;, p&amp;
Const nEl&amp; = 1000000, nCyc&amp; = 100
&nbsp;
<span class="kw4">ReDim</span> aLn(nEl)
<span class="kw4">ReDim</span> aBl(nEl)
<span class="kw4">ReDim</span> aBt(nEl)
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> nEl <span class="kw3">Step</span> 2
&nbsp; &nbsp; aLn(n) = 1
&nbsp; &nbsp; aBl(n) = <span class="kw5">True</span>
&nbsp; &nbsp; aBt(n) = 1
<span class="kw3">Next</span> n
&nbsp;
&nbsp;
t = Timer
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> nCyc &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">' =1/=-1 | &lt;&gt; 0 | Short</span>
 &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">For</span> e = 1 <span class="kw3">To</span> nEl
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If aLn(n) = 1 Then p = p + 1 &nbsp; ' 1.38 &nbsp; | 1.38 | 1.58</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If aBl(n) Then p = p + 1 &nbsp; &nbsp; &nbsp; ' 1.38 &nbsp; | 1.38 | 1.21</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If aBt(n) = 1 Then p = p + 1 &nbsp; ' 1.38 &nbsp; | 1.38 | 1.55</span>
 &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">Next</span> e
&nbsp; &nbsp; <span class="kw3">Next</span> n
Debug.<span class="kw4">Print</span> Format$(Timer - t, <span class="st0">&quot;0.00&quot;</span>), <span class="st0">&quot;Check&quot;</span>, p
&nbsp;
<span class="kw3">End</span> <span class="kw2">Sub</span></pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Продолжение. Новый, более быстрый, вариант</div>
				   <div class="spoiler-body">
					   Сделал много тестов. Они показывают, что новый метод деления строки НЕмедленнее (незаметно быстрее) старого, зато сцепка штатным <font color="Blue">Join</font>'ом [в этом случае, когда массив для сцепки не нужно готовить] быстрее предыдущего самого быстрого метода [с помощью наполнения буферной строки через Mid$()] около <b><font color="Red">3</font></b>ёх раз.<br />
Отрыв от регулярок на нормальных строках (53 символа, замена 3ёх или 6ти &quot;слов&quot;) стал ещё больше: ~ <b>45</b>%<br />
На сверхдлинных строках (530 символов, замена 30ти или 60ти &quot;слов&quot;) регулярки всё-ещё немного опережают: ~<b>3</b>%<br />
<br />
Также добавлены варианты, когда в функцию замены передаётся словарь, а не массив (&quot;_Fast&quot;) — это демонстрационный вариант для данного теста. В реальной ситуации, он не нужен (но работать будет - просто наполнение словаря вынесено из функции наружу). Видимый прирост скорости только на &quot;нормальных&quot; строках: ~ <b>10</b>%
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Файл</div>
				   <div class="spoiler-body">
					   <a href="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7873&amp;d=1673360792" >ReplaceWords_New.7z</a>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Код</div>
				   <div class="spoiler-body">
					   
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Модуль «Main»</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="725531314"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="725531314" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> TextMult(<span class="kw4">ByVal</span> v$, Mult&amp;, <span class="kw4">Optional</span> <span class="kw4">ByVal</span> Sep$ = <span class="st0">&quot; &quot;</span>) <span class="kw4">As</span> <span class="kw1">String</span>
<span class="kw4">Dim</span> tx$, n&amp;
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> Mult
&nbsp; &nbsp; tx = tx &amp; Sep &amp; v
<span class="kw3">Next</span> n
&nbsp;
TextMult = Mid$(tx, Len(Sep) + 1)
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Private</span> <span class="kw2">Sub</span> Test()
<span class="kw4">Dim</span> aFnd, aRpl
<span class="kw4">Dim</span> dic <span class="kw4">As</span> <span class="kw2">New</span> Dictionary, dicCI <span class="kw4">As</span> <span class="kw2">New</span> Dictionary
<span class="kw4">Dim</span> tx$, res$, t!, n&amp;, nR&amp;
Const nCyc&amp; = 100000, nMult&amp; = 10 &nbsp; <span class="co1">' nMult=1 Для проверки исходной строки</span>
&nbsp;
tx = <span class="st0">&quot;Вася вас не Вас,Петя:пет;не,Пет,Alexey-alex*not«Alex»&quot;</span>
aFnd = Array(<span class="st0">&quot;вас&quot;</span>, <span class="st0">&quot;пет&quot;</span>, <span class="st0">&quot;alex&quot;</span>)
aRpl = Array(<span class="st0">&quot;Василий Семёнович&quot;</span>, <span class="st0">&quot;Пётр Петрович&quot;</span>, <span class="st0">&quot;Jack&quot;</span>)
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aFnd)
&nbsp; &nbsp; dic.Add aFnd(n), aRpl(n)
&nbsp; &nbsp; dicCI.Add LCase$(aFnd(n)), aRpl(n)
<span class="kw3">Next</span> n
&nbsp;
tx = TextMult(tx, nMult)
&nbsp;
t = Timer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">' Исх. &nbsp;| x10</span>
 &nbsp; &nbsp;<span class="kw3">For</span> n = 1 <span class="kw3">To</span> nCyc / nMult
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = tx: nR = PRDX_Text_Replace_WholeWord_Array_Fast(res, dic) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 1.66 | 1.53</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = tx: nR = PRDX_Text_Replace_WholeWord_Array_Fast(res, dicCI, True) &nbsp; &nbsp; &nbsp; &nbsp;' 1.78 | 1.69</span>
&nbsp;
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = tx: nR = PRDX_Text_Replace_WholeWord_Array(res, aFnd, aRpl) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 1.86 | 1.55</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = tx: nR = PRDX_Text_Replace_WholeWord_Array(res, aFnd, aRpl, True) &nbsp; &nbsp; &nbsp; &nbsp;' 2.05 | 1.71</span>
&nbsp;
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = tx: nR = PRDX_Text_Replace_WholeWord_Array_Old(res, aFnd, aRpl) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 2.04 | 1.65</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = tx: nR = PRDX_Text_Replace_WholeWord_Array_Old(res, aFnd, aRpl, True) &nbsp; &nbsp;' 2.22 | 1.82</span>
&nbsp;
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = tx: nR = IG_ReplaceWholeWord_Array(res, aFnd, aRpl) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 2.64 | 1,48</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = tx: nR = IG_ReplaceWholeWord_Array(res, aFnd, aRpl, True) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' 2,98 | 1.66</span>
 &nbsp; &nbsp;<span class="kw3">Next</span> n
Debug.<span class="kw4">Print</span> Format$(Timer - t, <span class="st0">&quot;0.00&quot;</span>), nR
&nbsp;
<span class="kw3">End</span> <span class="kw2">Sub</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_Text_Replace_WholeWord(tmpString, <span class="kw4">ByVal</span> iFnd$, <span class="kw4">ByVal</span> iRpl$, <span class="kw4">Optional</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>, <span class="kw4">Optional</span> MsgFalse <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> aP$(), aI&amp;()
<span class="kw4">Dim</span> n&amp;, nRpl&amp;
&nbsp;
<span class="kw3">If</span> <span class="kw3">Not</span> PRDX_SplitString_ByNonCyrLat(tmpString, aP, aI, MsgFalse) <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp;
<span class="kw3">If</span> CaseIgnore <span class="kw3">Then</span>
&nbsp; &nbsp; iFnd = LCase$(iFnd)
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aI)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> iFnd = LCase$(aP(aI(n))) <span class="kw3">Then</span> nRpl = nRpl + 1: aP(aI(n)) = iRpl
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">Else</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aI)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> iFnd = aP(aI(n)) <span class="kw3">Then</span> nRpl = nRpl + 1: aP(aI(n)) = iRpl
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">If</span> nRpl = 0 <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
PRDX_Text_Replace_WholeWord = nRpl: tmpString = Join(aP, <span class="st0">&quot;&quot;</span>)
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_Text_Replace_WholeWord_Array(tmpString, aFind, aRpl, <span class="kw4">Optional</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>, <span class="kw4">Optional</span> MsgFalse <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> aP$(), aI&amp;()
<span class="kw4">Dim</span> tx$, f&amp;, n&amp;, nRpl&amp;
<span class="kw4">Static</span> st&amp;, dic <span class="kw4">As</span> Dictionary
&nbsp;
<span class="kw3">If</span> st = 0 <span class="kw3">Then</span> st = 1: <span class="kw4">Set</span> dic = <span class="kw2">New</span> Dictionary
<span class="kw3">If</span> <span class="kw3">Not</span> PRDX_SplitString_ByNonCyrLat(tmpString, aP, aI, MsgFalse) <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp;
<span class="kw3">If</span> CaseIgnore <span class="kw3">Then</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = <span class="kw4">LBound</span>(aFind) <span class="kw3">To</span> <span class="kw4">UBound</span>(aFind)
&nbsp; &nbsp; &nbsp; &nbsp; dic.Add LCase$(aFind(n)), aRpl(n)
&nbsp; &nbsp; <span class="kw3">Next</span> n
&nbsp;
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aI)
&nbsp; &nbsp; &nbsp; &nbsp; tx = LCase$(aP(aI(n)))
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> dic.Exists(tx) <span class="kw3">Then</span> nRpl = nRpl + 1: aP(aI(n)) = dic(tx)
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">Else</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = <span class="kw4">LBound</span>(aFind) <span class="kw3">To</span> <span class="kw4">UBound</span>(aFind)
&nbsp; &nbsp; &nbsp; &nbsp; dic.Add aFind(n), aRpl(n)
&nbsp; &nbsp; <span class="kw3">Next</span> n
&nbsp;
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aI)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> dic.Exists(aP(aI(n))) <span class="kw3">Then</span> nRpl = nRpl + 1: aP(aI(n)) = dic(tx)
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
dic.RemoveAll
<span class="kw3">If</span> nRpl = 0 <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
PRDX_Text_Replace_WholeWord_Array = nRpl: tmpString = Join(aP, <span class="st0">&quot;&quot;</span>)
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_Text_Replace_WholeWord_Array_Fast(tmpString, dic <span class="kw4">As</span> Dictionary, <span class="kw4">Optional</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>, <span class="kw4">Optional</span> MsgFalse <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> aP$(), aI&amp;()
<span class="kw4">Dim</span> tx$, f&amp;, n&amp;, nRpl&amp;
&nbsp;
<span class="kw3">If</span> <span class="kw3">Not</span> PRDX_SplitString_ByNonCyrLat(tmpString, aP, aI, MsgFalse) <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp;
<span class="kw3">If</span> CaseIgnore <span class="kw3">Then</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aI)
&nbsp; &nbsp; &nbsp; &nbsp; tx = LCase$(aP(aI(n)))
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> dic.Exists(tx) <span class="kw3">Then</span> nRpl = nRpl + 1: aP(aI(n)) = dic(tx)
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">Else</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aI)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> dic.Exists(aP(aI(n))) <span class="kw3">Then</span> nRpl = nRpl + 1: aP(aI(n)) = dic(tx)
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">If</span> nRpl = 0 <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
PRDX_Text_Replace_WholeWord_Array_Fast = nRpl: tmpString = Join(aP, <span class="st0">&quot;&quot;</span>)
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_Text_Replace_WholeWord_Old(tmpString, <span class="kw4">ByVal</span> iFnd$, <span class="kw4">ByVal</span> iRpl$, <span class="kw4">Optional</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> aWrd$(), aSep$()
<span class="kw4">Dim</span> n&amp;, l&amp;, nRpl&amp;
&nbsp;
<span class="kw3">If</span> <span class="kw3">Not</span> LCase$(tmpString) <span class="kw3">Like</span> <span class="st0">&quot;*[a-zёа-я]*&quot;</span> <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
<span class="kw3">If</span> <span class="kw3">Not</span> PRDX_SplitString_ByNonCyrLat_Old(tmpString, aWrd, aSep) <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
&nbsp;
<span class="kw3">If</span> CaseIgnore <span class="kw3">Then</span>
&nbsp; &nbsp; iFnd = LCase$(iFnd)
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> iFnd = LCase$(aWrd(n)) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(n) = iRpl
&nbsp; &nbsp; &nbsp; &nbsp; l = l + Len(aWrd(n)) + Len(aSep(n))
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">Else</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> iFnd = aWrd(n) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(n) = iRpl
&nbsp; &nbsp; &nbsp; &nbsp; l = l + Len(aWrd(n)) + Len(aSep(n))
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">If</span> nRpl = 0 <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
PRDX_Text_Replace_WholeWord_Old = nRpl
l = l + Len(aSep(n)): tmpString = PRDX_SplitString_ByNonCyrLat_Join(aWrd, aSep, l)
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_Text_Replace_WholeWord_Array_Old(tmpString, aFind, aRpl, <span class="kw4">Optional</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> aWrd$(), aSep$()
<span class="kw4">Dim</span> tx$, f&amp;, n&amp;, l&amp;, nRpl&amp;
<span class="kw4">Static</span> st&amp;, dic <span class="kw4">As</span> Dictionary
&nbsp;
<span class="kw3">If</span> <span class="kw3">Not</span> LCase$(tmpString) <span class="kw3">Like</span> <span class="st0">&quot;*[a-zёа-я]*&quot;</span> <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
<span class="kw3">If</span> st = 0 <span class="kw3">Then</span> st = 1: <span class="kw4">Set</span> dic = <span class="kw2">New</span> Dictionary
<span class="kw3">If</span> <span class="kw3">Not</span> PRDX_SplitString_ByNonCyrLat_Old(tmpString, aWrd, aSep) <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
&nbsp;
<span class="kw3">If</span> CaseIgnore <span class="kw3">Then</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = <span class="kw4">LBound</span>(aFind) <span class="kw3">To</span> <span class="kw4">UBound</span>(aFind)
&nbsp; &nbsp; &nbsp; &nbsp; tx = LCase$(aFind(n))
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> <span class="kw3">Not</span> dic.Exists(tx) <span class="kw3">Then</span> dic.Add tx, aRpl(n)
&nbsp; &nbsp; <span class="kw3">Next</span> n
&nbsp;
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; tx = LCase$(aWrd(n))
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> dic.Exists(tx) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(n) = dic(tx)
&nbsp; &nbsp; &nbsp; &nbsp; l = l + Len(aWrd(n)) + Len(aSep(n))
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">Else</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = <span class="kw4">LBound</span>(aFind) <span class="kw3">To</span> <span class="kw4">UBound</span>(aFind)
&nbsp; &nbsp; &nbsp; &nbsp; tx = aFind(n)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> <span class="kw3">Not</span> dic.Exists(tx) <span class="kw3">Then</span> dic.Add tx, aRpl(n)
&nbsp; &nbsp; <span class="kw3">Next</span> n
&nbsp;
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> dic.Exists(aWrd(n)) <span class="kw3">Then</span> nRpl = nRpl + 1: aWrd(n) = dic(aWrd(n))
&nbsp; &nbsp; &nbsp; &nbsp; l = l + Len(aWrd(n)) + Len(aSep(n))
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
dic.RemoveAll
<span class="kw3">If</span> nRpl = 0 <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
PRDX_Text_Replace_WholeWord_Array_Old = nRpl
l = l + Len(aSep(n)): tmpString = PRDX_SplitString_ByNonCyrLat_Join(aWrd, aSep, l)
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> IG_ReplaceWholeWord(tmpString, <span class="kw4">ByVal</span> iFnd$, <span class="kw4">ByVal</span> iRpl$, <span class="kw4">Optional</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Boolean</span>
<span class="kw4">Dim</span> x, tx$
<span class="kw4">Static</span> st&amp;, RE <span class="kw4">As</span> RegExp, REci <span class="kw4">As</span> RegExp
&nbsp;
<span class="kw3">If</span> st = 0 <span class="kw3">Then</span>
&nbsp; &nbsp; st = 1
&nbsp; &nbsp; <span class="kw4">Set</span> RE = <span class="kw2">New</span> RegExp: RE.Global = <span class="kw5">True</span>
&nbsp; &nbsp; <span class="kw4">Set</span> REci = <span class="kw2">New</span> RegExp: REci.Global = <span class="kw5">True</span>: REci.IgnoreCase = <span class="kw5">True</span>
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">If</span> CaseIgnore <span class="kw3">Then</span>
&nbsp; &nbsp; tx = <span class="st0">&quot;(^|[^a-zа-яё])&quot;</span> &amp; iFnd &amp; <span class="st0">&quot;(?=[^a-zа-яё]|$)&quot;</span>
&nbsp; &nbsp; <span class="kw3">If</span> REci.Pattern &lt;&gt; tx <span class="kw3">Then</span> REci.Pattern = tx
&nbsp;
&nbsp; &nbsp; <span class="kw3">If</span> REci.Test(tmpString) <span class="kw3">Then</span> IG_ReplaceWholeWord = <span class="kw5">True</span> <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp; &nbsp; tmpString = REci.Replace(tmpString, <span class="st0">&quot;$1&quot;</span> &amp; iRpl)
<span class="kw3">Else</span>
&nbsp; &nbsp; tx = <span class="st0">&quot;(^|[^A-Za-zА-яЁё])&quot;</span> &amp; iFnd &amp; <span class="st0">&quot;(?=[^A-Za-zА-яЁё]|$)&quot;</span>
&nbsp; &nbsp; <span class="kw3">If</span> RE.Pattern &lt;&gt; tx <span class="kw3">Then</span> RE.Pattern = tx
&nbsp;
&nbsp; &nbsp; <span class="kw3">If</span> RE.Test(tmpString) <span class="kw3">Then</span> IG_ReplaceWholeWord = <span class="kw5">True</span> <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp; &nbsp; tmpString = RE.Replace(tmpString, <span class="st0">&quot;$1&quot;</span> &amp; iRpl)
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> IG_ReplaceWholeWord_Array(tmpString, aFind, aRpl, <span class="kw4">Optional</span> CaseIgnore <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Boolean</span>
<span class="kw4">Dim</span> x, n&amp;
<span class="kw4">Static</span> st&amp;, RE <span class="kw4">As</span> RegExp, REci <span class="kw4">As</span> RegExp
&nbsp;
<span class="kw3">If</span> st = 0 <span class="kw3">Then</span>
&nbsp; &nbsp; st = 1
&nbsp; &nbsp; <span class="kw4">Set</span> RE = <span class="kw2">New</span> RegExp: RE.Global = <span class="kw5">True</span>
&nbsp; &nbsp; <span class="kw4">Set</span> REci = <span class="kw2">New</span> RegExp: REci.Global = <span class="kw5">True</span>: REci.IgnoreCase = <span class="kw5">True</span>
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">If</span> CaseIgnore <span class="kw3">Then</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = <span class="kw4">LBound</span>(aFind) <span class="kw3">To</span> <span class="kw4">UBound</span>(aFind)
&nbsp; &nbsp; &nbsp; &nbsp; REci.Pattern = <span class="st0">&quot;(^|[^a-zа-яё])&quot;</span> &amp; aFind(n) &amp; <span class="st0">&quot;(?=[^a-zа-яё]|$)&quot;</span>
&nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> REci.Test(tmpString) <span class="kw3">Then</span> IG_ReplaceWholeWord_Array = <span class="kw5">True</span> <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp; &nbsp; &nbsp; &nbsp; tmpString = REci.Replace(tmpString, <span class="st0">&quot;$1&quot;</span> &amp; aRpl(n))
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">Else</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = <span class="kw4">LBound</span>(aFind) <span class="kw3">To</span> <span class="kw4">UBound</span>(aFind)
&nbsp; &nbsp; &nbsp; &nbsp; RE.Pattern = <span class="st0">&quot;(^|[^A-Za-zА-яЁё])&quot;</span> &amp; aFind(n) &amp; <span class="st0">&quot;(?=[^A-Za-zА-яЁё]|$)&quot;</span>
&nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> RE.Test(tmpString) <span class="kw3">Then</span> IG_ReplaceWholeWord_Array = <span class="kw5">True</span> <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp; &nbsp; &nbsp; &nbsp; tmpString = RE.Replace(tmpString, <span class="st0">&quot;$1&quot;</span> &amp; aRpl(n))
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw3">End</span> <span class="kw3">If</span>
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
'==================================================================================================</pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Модуль «Splitter»</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="578636925"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="578636925" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_SplitString_ByNonCyrLat(<span class="kw4">ByVal</span> iStr$, aPart$(), aInd&amp;(), <span class="kw4">Optional</span> MsgFalse <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Boolean</span>
<span class="kw4">Dim</span> aBt() <span class="kw4">As</span> <span class="kw1">Byte</span>
<span class="kw4">Dim</span> i&amp;, n&amp;, nP&amp;, nI&amp;, bW&amp;, bS&amp;
&nbsp;
aBt = iStr
<span class="kw4">ReDim</span> aPart(Len(iStr))
<span class="kw4">ReDim</span> aInd(<span class="kw4">UBound</span>(aPart))
&nbsp;
<span class="kw3">For</span> i = 0 <span class="kw3">To</span> <span class="kw4">UBound</span>(aBt) <span class="kw3">Step</span> 2
&nbsp; &nbsp; n = n + 1
&nbsp;
&nbsp; &nbsp; <span class="kw3">If</span> PRDX_AscW_CyrAndLat_Is(aBt(i) + 256 * aBt(i + 1)) <span class="kw3">Then</span> &nbsp; <span class="co1">' Ltr</span>
 &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">If</span> bW <span class="kw3">Then</span> <span class="kw3">GoTo</span> nx <span class="kw3">Else</span> bW = n
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> bS = 0 <span class="kw3">Then</span> <span class="kw3">GoTo</span> nx
&nbsp; &nbsp; &nbsp; &nbsp; nP = nP + 1: aPart(nP) = Mid$(iStr, bS, n - bS): bS = 0
&nbsp; &nbsp; <span class="kw3">Else</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">' NonLtr</span>
 &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">If</span> bS <span class="kw3">Then</span> <span class="kw3">GoTo</span> nx <span class="kw3">Else</span> bS = n
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> bW = 0 <span class="kw3">Then</span> <span class="kw3">GoTo</span> nx
&nbsp; &nbsp; &nbsp; &nbsp; nP = nP + 1: aPart(nP) = Mid$(iStr, bW, n - bW): bW = 0
&nbsp; &nbsp; &nbsp; &nbsp; nI = nI + 1: aInd(nI) = nP
&nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
nx:
<span class="kw3">Next</span> i
&nbsp;
<span class="kw3">If</span> bW <span class="kw3">Then</span>
&nbsp; &nbsp; nP = nP + 1: aPart(nP) = Mid$(iStr, bW)
&nbsp; &nbsp; nI = nI + 1: aInd(nI) = nP
<span class="kw3">Else</span>
&nbsp; &nbsp; <span class="kw3">If</span> nI = 0 <span class="kw3">Then</span> <span class="kw3">If</span> MsgFalse <span class="kw3">Then</span> MsgBox <span class="st0">&quot;There is NO any Cyr/Lat letters in String&quot;</span> &amp; vbLf &amp; iStr, vbCritical, <span class="st0">&quot;PRDX_SplitString_ByNonCyrLat&quot;</span>: <span class="kw2">Exit</span> <span class="kw2">Function</span> <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp; &nbsp; nP = nP + 1: aPart(nP) = Mid$(iStr, bS)
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw4">ReDim</span> <span class="kw4">Preserve</span> aPart(nP)
<span class="kw4">ReDim</span> <span class="kw4">Preserve</span> aInd(nI)
PRDX_SplitString_ByNonCyrLat = nI
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'--------------------------------------------------------------------------------------------------</span>
<span class="kw2">Private</span> <span class="kw2">Sub</span> Test_PRDX_SplitString_ByNonCyrLat()
<span class="kw4">Dim</span> aP$(), aI&amp;()
<span class="kw4">Dim</span> x, n&amp;, i&amp;
&nbsp;
x = <span class="st0">&quot;./.asd.gh./*красота/*b./7jg&quot;</span>
<span class="co1">'x = &quot;,/&quot;</span>
<span class="kw3">If</span> PRDX_SplitString_ByNonCyrLat(x, aP, aI, <span class="kw5">True</span>) <span class="kw3">Then</span> i = 1 <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Sub</span>
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aP)
&nbsp; &nbsp; Debug.<span class="kw4">Print</span> n, <span class="st0">&quot;«&quot;</span> &amp; aP(n) &amp; <span class="st0">&quot;»&quot;</span>,
&nbsp; &nbsp; <span class="kw3">If</span> aI(i) = n <span class="kw3">Then</span> Debug.<span class="kw4">Print</span> 1: i = i + 1 <span class="kw3">Else</span> Debug.<span class="kw4">Print</span> 0
<span class="kw3">Next</span> n
&nbsp;
Debug.<span class="kw4">Print</span> Join(aP, <span class="st0">&quot;&quot;</span>) = x
<span class="kw3">End</span> <span class="kw2">Sub</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">' Fill aWrd(N) and aSep(N+1)</span>
<span class="kw2">Function</span> PRDX_SplitString_ByNonCyrLat_Old(<span class="kw4">ByVal</span> iStr$, aWrd$(), aSep$()) <span class="kw4">As</span> <span class="kw1">Boolean</span>
<span class="kw4">Dim</span> aBt() <span class="kw4">As</span> <span class="kw1">Byte</span>
<span class="kw4">Dim</span> i&amp;, n&amp;, nW&amp;, nS&amp;, bW&amp;, bS&amp;
&nbsp;
aBt = iStr
<span class="kw4">ReDim</span> aWrd(Len(iStr))
<span class="kw4">ReDim</span> aSep(<span class="kw4">UBound</span>(aWrd))
&nbsp;
<span class="kw3">For</span> i = 0 <span class="kw3">To</span> <span class="kw4">UBound</span>(aBt) <span class="kw3">Step</span> 2
&nbsp; &nbsp; n = n + 1
&nbsp;
&nbsp; &nbsp; <span class="kw3">If</span> PRDX_AscW_CyrAndLat_Is(aBt(i) + 256 * aBt(i + 1)) <span class="kw3">Then</span> &nbsp; <span class="co1">' Ltr</span>
 &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">If</span> bW <span class="kw3">Then</span> <span class="kw3">GoTo</span> nx <span class="kw3">Else</span> bW = n
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> bS = 0 <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> nS = 0 <span class="kw3">Then</span> nS = nS + 1: aSep(nS) = <span class="st0">&quot;&quot;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">GoTo</span> nx
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; nS = nS + 1: aSep(nS) = Mid$(iStr, bS, n - bS): bS = 0
&nbsp; &nbsp; <span class="kw3">Else</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">' NonLtr</span>
 &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw3">If</span> bS <span class="kw3">Then</span> <span class="kw3">GoTo</span> nx <span class="kw3">Else</span> bS = n
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> bW = 0 <span class="kw3">Then</span> <span class="kw3">GoTo</span> nx
&nbsp; &nbsp; &nbsp; &nbsp; nW = nW + 1: aWrd(nW) = Mid$(iStr, bW, n - bW): bW = 0
&nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
nx:
<span class="kw3">Next</span> i
&nbsp;
<span class="kw3">If</span> bW <span class="kw3">Then</span>
&nbsp; &nbsp; nW = nW + 1: aWrd(nW) = Mid$(iStr, bW)
<span class="kw3">Else</span>
&nbsp; &nbsp; nS = nS + 1: aSep(nS) = Mid$(iStr, bS)
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">If</span> nW = 0 <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
<span class="kw3">If</span> nS &lt; nW <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
<span class="kw3">If</span> nS &gt; nW + 1 <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
<span class="kw3">If</span> nS = nW <span class="kw3">Then</span> nS = nS + 1: aSep(nS) = <span class="st0">&quot;&quot;</span>
&nbsp;
<span class="kw4">ReDim</span> <span class="kw4">Preserve</span> aWrd(nW)
<span class="kw4">ReDim</span> <span class="kw4">Preserve</span> aSep(nS)
PRDX_SplitString_ByNonCyrLat_Old = <span class="kw5">True</span>
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'--------------------------------------------------------------------------------------------------</span>
<span class="kw2">Private</span> <span class="kw2">Sub</span> Test_PRDX_SplitString_ByNonCyrLat_Old()
<span class="kw4">Dim</span> x, w$(), s$(), n&amp;
&nbsp;
x = <span class="st0">&quot;,./asd.gh./*красота/*b./7jg,,./&quot;</span>
<span class="kw3">If</span> <span class="kw3">Not</span> PRDX_SplitString_ByNonCyrLat_Old(x, w, s) <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Sub</span>
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(s)
&nbsp; &nbsp; Debug.<span class="kw4">Print</span> <span class="st0">&quot;«&quot;</span> &amp; s(n) &amp; <span class="st0">&quot;»&quot;</span>
&nbsp; &nbsp; <span class="kw3">If</span> n &lt; <span class="kw4">UBound</span>(s) <span class="kw3">Then</span> Debug.<span class="kw4">Print</span> <span class="st0">&quot;«&quot;</span> &amp; w(n) &amp; <span class="st0">&quot;»&quot;</span>
<span class="kw3">Next</span> n
&nbsp;
Debug.<span class="kw4">Print</span> x = PRDX_SplitString_ByNonCyrLat_Join(w, s, Len(x))
<span class="kw3">End</span> <span class="kw2">Sub</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> PRDX_SplitString_ByNonCyrLat_Join(aWrd$(), aSep$(), iLen&amp;) <span class="kw4">As</span> <span class="kw1">String</span>
<span class="kw4">Dim</span> tx$, n&amp;, p&amp;, l&amp;
&nbsp;
tx = <span class="kw1">String</span>$(iLen, <span class="st0">&quot; &quot;</span>): p = 1
&nbsp;
l = Len(aSep(1))
<span class="kw3">If</span> l <span class="kw3">Then</span> Mid$(tx, p, l) = aSep(1): &nbsp; &nbsp; &nbsp; &nbsp; p = p + l
l = Len(aWrd(1)): Mid$(tx, p, l) = aWrd(1): p = p + l
&nbsp;
<span class="kw3">For</span> n = 2 <span class="kw3">To</span> <span class="kw4">UBound</span>(aWrd)
&nbsp; &nbsp; l = Len(aSep(n)): Mid$(tx, p, l) = aSep(n): p = p + l
&nbsp; &nbsp; l = Len(aWrd(n)): Mid$(tx, p, l) = aWrd(n): p = p + l
<span class="kw3">Next</span> n
&nbsp;
l = Len(aSep(n))
<span class="kw3">If</span> l <span class="kw3">Then</span> Mid$(tx, p, l) = aSep(n)
&nbsp;
PRDX_SplitString_ByNonCyrLat_Join = tx
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Private</span> <span class="kw2">Sub</span> SpeedTest()
<span class="kw4">Dim</span> tx$, res$, t!, n&amp;, l&amp;, f <span class="kw4">As</span> <span class="kw1">Boolean</span>
<span class="kw4">Dim</span> aP$(), aI&amp;()
<span class="kw4">Dim</span> aWrd$(), aSep$()
Const nCyc&amp; = 1000000
&nbsp;
tx = <span class="st0">&quot;Вася вас не Вас,Петя:пет;не,Пет,Alexey-alex*not«Alex»&quot;</span>
l = Len(tx)
&nbsp;
t = Timer
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> nCyc / 10
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;f = PRDX_SplitString_ByNonCyrLat_Old(tx, aWrd, aSep) &nbsp; ' 1.44</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;f = PRDX_SplitString_ByNonCyrLat(tx, aP, aI) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' 1.41</span>
 &nbsp; &nbsp;<span class="kw3">Next</span> n
Debug.<span class="kw4">Print</span> Format$(Timer - t, <span class="st0">&quot;0.00&quot;</span>), <span class="st0">&quot;Split&quot;</span>, f
&nbsp;
t = Timer
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> nCyc
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = PRDX_SplitString_ByNonCyrLat_Join(aWrd, aSep, l) ' 1.06</span>
<span class="co1">' &nbsp; &nbsp; &nbsp; &nbsp;res = Join(aP, &quot;&quot;) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' 0.38</span>
 &nbsp; &nbsp;<span class="kw3">Next</span> n
Debug.<span class="kw4">Print</span> Format$(Timer - t, <span class="st0">&quot;0.00&quot;</span>), <span class="st0">&quot;Join&quot;</span>, res = tx
&nbsp;
<span class="kw3">End</span> <span class="kw2">Sub</span>
'==================================================================================================</pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
				   </div>
			   </div>
				   </div>
			   </div></div>

]]></content:encoded>
			<dc:creator>Jack Famous</dc:creator>
			<guid isPermaLink="true">https://www.cyberforum.ru/blogs/1808109/7879.html</guid>
		</item>
		<item>
			<title>Список символов, которые допустимы в качестве 1го символа именованного диапазона / List of Symbols for Name prefix</title>
			<link>https://www.cyberforum.ru/blogs/1808109/7835.html</link>
			<pubDate>Tue, 06 Dec 2022 13:53:52 GMT</pubDate>
			<description>*Приветствую!* 
Создал процедурку, которая выводит перечень всех символов, которые допускается...</description>
			<content:encoded><![CDATA[<div><b>Приветствую!</b><br />
Создал процедурку, которая выводит перечень всех символов, которые допускается использовать в качестве префикса (1го символа) наименования именованного диапазона.
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Для чего (конкретный реальный пример):</div>
				   <div class="spoiler-body">
					   У меня есть набор функций для проверки умной Таблицы с выводом результата в 1ый столбец. При этом все проверки прописываются (по определённому синтаксису) в комментариях именованных диапазонов к полям (одно имя = одна ячейка заголовка. Можно не делать проверяемыми все поля, а столько, сколько нужно). Чтобы быстро отфильтровать из всего перечня имён книги те, которые являются служебными и участвуют в проверке, я использую префикс параграфа <b>§</b>.<br />
С ростом <b>видов</b> служебных имён (для проверки Таблицы - только один из видов) возникла потребность в уникальных префиксах для них.
				   </div>
			   </div><br />
<b><font color="Red">Внимание!</font></b><br />
Код работает порядка 10 минут и выводит список более 50 тыс символов, из которых бОльшая часть вам точно не нужна.
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Из этого огромного перечня я оставил «всего лишь» 820 символов, которые разбил на 4 категории по удобству использования:</div>
				   <div class="spoiler-body">
					   <ul><li>1 — символы, которые хорошо видны в качестве префикса и их можно скопировать или ввести в VBA без использования функции <font color="Blue">ChrW$()</font>. Все остальные символы нужно вводить через эту функцию (но это неточно — может как-то ещё можно). Использую пока что только этот набор.</li>
<li>2 — дополнительный набор интересных символов.</li>
<li>3 — символы, которые вряд ли понадобятся. Некоторые очень похожи внешне на символы наборов 1 и 2.</li>
<li>(без категории) — символы, которые могут быть вам полезны, но не полезны мне</li>
</ul>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Скрин, Файл и Код</div>
				   <div class="spoiler-body">
					   
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Скрин</div>
				   <div class="spoiler-body">
					   <a href="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7836&amp;d=1670334567" rel="Lightbox" id="attachment7836" ><img src="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7836&amp;thumb=1&amp;d=1670334567" class="thumbnail" border="0" alt="Нажмите на изображение для увеличения
Название: Снимок.PNG
Просмотров: 324
Размер:	16.2 Кб
ID:	7836" style="margin: 5px" /></a>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Файл</div>
				   <div class="spoiler-body">
					   <a href="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7837&amp;d=1670334608" >SymbolsForName.7z</a>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Код</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="666127340"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="666127340" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="co1">' РАБОТАЕТ 10 минут !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<span class="kw2">Sub</span> Test()
<span class="kw4">Dim</span> aSym()
<span class="kw4">Dim</span> tx$, ch$, t!, n&amp;, r&amp;
Const nn&amp; = 65535
&nbsp;
t = Timer
tx = <span class="st0">&quot;abcd&quot;</span>
<span class="kw4">ReDim</span> aSym(nn, 2) <span class="co1">' AscW, Char</span>
&nbsp;
<span class="kw4">On</span> <span class="kw4">Error</span> <span class="kw4">Resume</span> <span class="kw3">Next</span>
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> nn
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> n = 32 <span class="kw3">Then</span> n = 33
&nbsp; &nbsp; &nbsp; &nbsp; ch = ChrW(n): <span class="kw3">If</span> Err <span class="kw3">Then</span> <span class="kw4">Stop</span>
&nbsp; &nbsp; &nbsp; &nbsp; ActiveWorkbook.Names.Add ch &amp; tx, [a1]
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> Err.Number = 0 <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r = r + 1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aSym(r, 1) = n
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aSym(r, 2) = ch
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ActiveWorkbook.Names(ch &amp; tx).Delete
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> Err <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Err.Clear
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
&nbsp; &nbsp; <span class="kw3">Next</span> n
<span class="kw4">On</span> <span class="kw4">Error</span> <span class="kw3">GoTo</span> 0
&nbsp;
<span class="kw3">If</span> r = 0 <span class="kw3">Then</span> <span class="kw4">Stop</span>: <span class="kw3">End</span>
[a2].Resize(nn, 2).ClearContents
[a2].Resize(r, 2).Value2 = aSym
&nbsp;
MsgBox <span class="st0">&quot;Find&amp;Load Symbols: &quot;</span> &amp; Format$(r, <span class="st0">&quot;#,##0&quot;</span>), vbInformation, Format$(Timer - t, <span class="st0">&quot;0.00&quot;</span>)
<span class="kw3">End</span> <span class="kw2">Sub</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Sub</span> ShowSelected()
<span class="kw4">Dim</span> cl <span class="kw4">As</span> Range
&nbsp; &nbsp; <span class="kw3">For</span> <span class="kw3">Each</span> cl <span class="kw3">In</span> Selection
&nbsp; &nbsp; &nbsp; &nbsp; Debug.<span class="kw4">Print</span> cl.Row, cl
&nbsp; &nbsp; <span class="kw3">Next</span> cl
<span class="kw3">End</span> <span class="kw2">Sub</span>
'==================================================================================================</pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
				   </div>
			   </div></div>

]]></content:encoded>
			<dc:creator>Jack Famous</dc:creator>
			<guid isPermaLink="true">https://www.cyberforum.ru/blogs/1808109/7835.html</guid>
		</item>
		<item>
			<title>Диапазон в строку/Range to String</title>
			<link>https://www.cyberforum.ru/blogs/1808109/7821.html</link>
			<pubDate>Tue, 29 Nov 2022 13:07:26 GMT</pubDate>
			<description><![CDATA[*Приветствую!* 
Сделал функцию для получения строки из диапазона. Работает [в том числе и] с...]]></description>
			<content:encoded><![CDATA[<div><b>Приветствую!</b><br />
Сделал функцию для получения строки из диапазона. Работает [в том числе и] с произвольно выделенными диапазонами (через Ctrl) в любом порядке.<br />
Функция родилась из обсуждения <b><a rel="nofollow noopener noreferrer" href="https://www.planetaexcel.ru/forum/index.php?PAGE_NAME=message&amp;FID=1&amp;TID=153731&amp;TITLE_SEO=153731-kopirovanie-iz-excel-v-drugie-prilozheniya-tolko-vydelennye-yacheyki&amp;MID=1226477&amp;tags=Word&amp;amp%3BFID=1#message1226477" target="_blank" title="https://www.planetaexcel.ru/forum/index.php?PAGE_NAME=message&amp;FID=1&amp;TID=153731&amp;TITLE_SEO=153731-kopirovanie-iz-excel-v-drugie-prilozheniya-tolko-vydelennye-yacheyki&amp;MID=1226477&amp;tags=Word&amp;amp%3BFID=1#message1226477">в этой теме на Планете</a></b>. Обсуждалась проблема копирования несмежных ячеек из Excel и данная функция эту проблему решает (остаётся только строку передать в буфер).<br />
<br />
<u>Функция является высокопроизводительной:</u> в частности, работает с координатами областей вместо адресов, а для сортировки используется рекурсивная <font color="Blue">QuickSort</font>, заточенная конкретно под эту задачу.
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Что делает</div>
				   <div class="spoiler-body">
					   <br />
     • позволяет (требует) указать разделители для строк и столбцов<br />
     • не привязана к порядку выделения ячеек<br />
     • отменяет выполнение, если в ячейке содержится разделитель для строк или столбцов. Это нужно, чтобы получившаяся строка гарантировала структуру исходных данных
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Что НЕ делает</div>
				   <div class="spoiler-body">
					   <br />
     • НЕ контролирует, была ли ячейка выделена дважды<br />
     • НЕ контролирует ячейки с ошибками и пустые - ошибки вызовут (сюрприз) ошибку, а пустые участвуют в сцепке наравне с остальными данными
				   </div>
			   </div>Любые &quot;свистоперделки&quot; могу прикрутить по вашему желанию за символическую плату 8-)<br />
<br />

			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Скрин</div>
				   <div class="spoiler-body">
					   <a href="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7821&amp;d=1669726319" rel="Lightbox" id="attachment7821" ><img src="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7821&amp;thumb=1&amp;d=1669726319" class="thumbnail" border="0" alt="Нажмите на изображение для увеличения
Название: RngToString.PNG
Просмотров: 317
Размер:	40.2 Кб
ID:	7821" style="margin: 5px" /></a>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Файл</div>
				   <div class="spoiler-body">
					   <a href="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7820&amp;d=1669726319" >RangeToString.7z</a>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Код</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="700239976"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="700239976" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="kw2">Option</span> <span class="kw2">Private</span> Module
<span class="co1">'==================================================================================================</span>
<span class="kw2">Sub</span> Test()
<span class="kw4">Dim</span> tx$
Const sepVis&amp; = 9553 <span class="co1">' separator for visual format</span>
&nbsp;
&nbsp; &nbsp; <span class="kw3">If</span> <span class="kw3">Not</span> Rng_ToString([_rngTest], tx, vbCrLf, vbTab) <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Sub</span>
&nbsp;
&nbsp; &nbsp; [_clRes] = tx
&nbsp; &nbsp; [_clShow] = Replace$(tx, vbTab, ChrW(sepVis))
&nbsp; &nbsp; MsgBox <span class="st0">&quot;DONE&quot;</span>
<span class="kw3">End</span> <span class="kw2">Sub</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> Rng_ToString(rng <span class="kw4">As</span> Range, txRes$, sepRows$, sepColumns$) <span class="kw4">As</span> <span class="kw1">Boolean</span>
<span class="kw4">Dim</span> arr, tx$, i&amp;, a&amp;, n&amp;, r&amp;, c&amp;, rr&amp;, cc&amp;, fR&amp;, fC&amp;, fChange&amp;
<span class="kw4">Static</span> aOne(1, 1), aData(), aRC$()
&nbsp;
<span class="co1">' Prepare =======================================</span>
a = rng.Cells.Count
<span class="kw3">If</span> a = 1 <span class="kw3">Then</span> txRes = rng.Value: Rng_ToString = <span class="kw5">True</span>: <span class="kw2">Exit</span> <span class="kw2">Function</span>
<span class="kw4">ReDim</span> aRC(a)
<span class="kw4">ReDim</span> aData(a)
&nbsp;
<span class="co1">' Main cycle ====================================</span>
<span class="kw3">For</span> a = 1 <span class="kw3">To</span> rng.Areas.Count
&nbsp; &nbsp; <span class="kw3">With</span> rng.Areas(a)
&nbsp; &nbsp; &nbsp; &nbsp; arr = .Value
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> <span class="kw3">Not</span> IsArray(arr) <span class="kw3">Then</span> aOne(1, 1) = arr: arr = aOne
&nbsp; &nbsp; &nbsp; &nbsp; fR = .Row - 1
&nbsp; &nbsp; &nbsp; &nbsp; fC = .Column - 1
&nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">With</span>
&nbsp;
&nbsp; &nbsp; <span class="kw3">For</span> c = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(arr, 2)
&nbsp; &nbsp; &nbsp; &nbsp; cc = fC + c
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">For</span> r = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(arr, 1)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rr = fR + r
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tx = Format$(rr, <span class="st0">&quot;0000000&quot;</span>) &amp; Format$(cc, <span class="st0">&quot;00000&quot;</span>)
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n = n + 1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aRC(n) = tx
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aData(n) = arr(r, c)
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> InStr(aData(n), sepRows) <span class="kw3">Then</span> MsgBox <span class="st0">&quot;Find Rows separator «&quot;</span> &amp; sepRows &amp; <span class="st0">&quot;» In Value «&quot;</span> &amp; arr(r, c) &amp; <span class="st0">&quot;»!&quot;</span>, vbCritical, <span class="st0">&quot;Rng_ToString&quot;</span>: <span class="kw3">GoTo</span> ex
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> InStr(aData(n), sepColumns) <span class="kw3">Then</span> MsgBox <span class="st0">&quot;Find Columns separator «&quot;</span> &amp; sepColumns &amp; <span class="st0">&quot;» In Value «&quot;</span> &amp; arr(r, c) &amp; <span class="st0">&quot;»!&quot;</span>, vbCritical, <span class="st0">&quot;Rng_ToString&quot;</span>: <span class="kw3">GoTo</span> ex
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Next</span> r
&nbsp; &nbsp; <span class="kw3">Next</span> c
<span class="kw3">Next</span> a
&nbsp;
<span class="co1">' Sort ==========================================</span>
<span class="kw4">ReDim</span> <span class="kw4">Preserve</span> aRC(n)
<span class="kw4">ReDim</span> <span class="kw4">Preserve</span> aData(n)
SortRecur_a1D_SecByMain aRC, aData, 1, n
&nbsp;
<span class="co1">' StringCreate ==================================</span>
txRes = aData(1)
r = Left$(aRC(1), 7) &nbsp; &nbsp;<span class="co1">' cut Row from Format</span>
&nbsp;
<span class="kw3">For</span> n = 2 <span class="kw3">To</span> <span class="kw4">UBound</span>(aRC)
&nbsp; &nbsp; rr = Left$(aRC(n), 7)
&nbsp;
&nbsp; &nbsp; <span class="kw3">If</span> rr = r <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; txRes = txRes &amp; sepColumns &amp; aData(n)
&nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; txRes = txRes &amp; sepRows &amp; aData(n)
&nbsp; &nbsp; &nbsp; &nbsp; r = rr
&nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
<span class="kw3">Next</span> n
&nbsp;
Rng_ToString = <span class="kw5">True</span>
ex: arr = 0: Erase aRC: Erase aData
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Sub</span> SortRecur_a1D_SecByMain(aMain$(), aSecondary(), LB&amp;, UB&amp;)
<span class="kw4">Dim</span> x, tx$, i&amp;, j&amp;
&nbsp;
i = LB: j = UB: tx = aMain((LB + UB) \ 2)
&nbsp;
<span class="kw3">Do</span>
&nbsp; &nbsp; <span class="kw3">Do</span> <span class="kw3">While</span> aMain(i) &lt; tx: i = i + 1: <span class="kw3">Loop</span>
&nbsp; &nbsp; <span class="kw3">Do</span> <span class="kw3">While</span> tx &lt; aMain(j): j = j - 1: <span class="kw3">Loop</span>
&nbsp; &nbsp; <span class="kw3">If</span> i &lt;= j <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; tx = aMain(i): aMain(i) = aMain(j): aMain(j) = tx
&nbsp; &nbsp; &nbsp; &nbsp; x = aSecondary(i): aSecondary(i) = aSecondary(j): aSecondary(j) = x
&nbsp; &nbsp; &nbsp; &nbsp; i = i + 1: j = j - 1
&nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
<span class="kw3">Loop</span> <span class="kw3">Until</span> i &gt; j
&nbsp;
<span class="kw3">If</span> LB &lt; j <span class="kw3">Then</span> SortRecur_a1D_SecByMain aMain, aSecondary, LB, j
<span class="kw3">If</span> i &lt; UB <span class="kw3">Then</span> SortRecur_a1D_SecByMain aMain, aSecondary, i, UB
<span class="kw3">End</span> <span class="kw2">Sub</span></pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div></div>

]]></content:encoded>
			<dc:creator>Jack Famous</dc:creator>
			<guid isPermaLink="true">https://www.cyberforum.ru/blogs/1808109/7821.html</guid>
		</item>
		<item>
			<title>Быстрое и готовое решение для работы с градусами/VBA.Fast and ready-made solution for work with Degrees</title>
			<link>https://www.cyberforum.ru/blogs/1808109/7801.html</link>
			<pubDate>Fri, 18 Nov 2022 14:10:14 GMT</pubDate>
			<description>*Приветствую!* 
Моя первая запись. 
 
Написал перечень функций и процедур для работы с градусами,...</description>
			<content:encoded><![CDATA[<div><b>Приветствую!</b><br />
Моя первая запись.<br />
<br />
Написал перечень функций и процедур для работы с градусами, минутами и секундами. Данная работа является подготовкой к созданию модуля для операций с датой-временем (там похожий принцип).<br />
Этот код подойдёт для практикующих разработчиков на VBA, как готовое решение, заточенное на высокую скорость работы.<br />
Постарался оттестировать, но мог что-то пропустить.<br />
<br />
<u>Код может:</u><br />
     • быстро разбирать строки вида <b><i><font color="Blue">1°1'1''</font></i></b>, <b><i><font color="blue">-10°11'12''</font></i></b>, <b><i><font color="blue">-10°1'</font></i></b>, <b><i><font color="blue">1°111''</font></i></b>, <b><i><font color="blue">12'1''</font></i></b>, <b><i><font color="blue">12°</font></i></b>, <b><i><font color="blue">-15'</font></i></b>, <b><i><font color="blue">10''</font></i></b> в одномерный массив (от 0 до 3): ЗначениеВСекундах, Градусы, Минуты, Секунды.<br />
     • не разбирать строку, а просто проверить её на соответствие.<br />
     • перевести в одномерный массив, как выше, значение в секундах<br />
     • создать из массива, как выше, строку<br />
     • преобразовать градусы больше 360 и меньше 0<br />
<br />

			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Скрин работы UDF на листе</div>
				   <div class="spoiler-body">
					   <a href="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7800&amp;d=1668780590" rel="Lightbox" id="attachment7800" ><img src="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7800&amp;thumb=1&amp;d=1668780590" class="thumbnail" border="0" alt="Нажмите на изображение для увеличения
Название: Снимок.PNG
Просмотров: 336
Размер:	13.9 Кб
ID:	7800" style="margin: 5px" /></a>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Файл</div>
				   <div class="spoiler-body">
					   <a href="https://www.cyberforum.ru/blog_attachment.php?attachmentid=7801&amp;d=1668780590" >Degrees.7z</a>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Код</div>
				   <div class="spoiler-body">
					   
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">&quot;Модуль «UDF»&quot;</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="72686650"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="72686650" style="height: 254px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> UDF_Degree_StringToSec(iString$) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> aL3(0 <span class="kw3">To</span> 3) <span class="kw4">As</span> <span class="kw1">Long</span>
&nbsp; &nbsp; Degrees_Str_ToArrL3 iString, aL3
&nbsp; &nbsp; UDF_Degree_StringToSec = aL3(0)
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> UDF_Degree_SecToString(iSec&amp;, <span class="kw4">Optional</span> SkipZeros <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">String</span>
<span class="kw4">Dim</span> aL3(0 <span class="kw3">To</span> 3) <span class="kw4">As</span> <span class="kw1">Long</span>
&nbsp; &nbsp; Degrees_Sec_ToArrL3 iSec, aL3
&nbsp; &nbsp; UDF_Degree_SecToString = Degrees_ArrL3_ToStr(aL3, SkipZeros)
<span class="kw3">End</span> <span class="kw2">Function</span>
'==================================================================================================</pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Модуль «Тест»</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="294211369"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="294211369" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Sub</span> FullTest()
<span class="kw4">Dim</span> aStr(), aArrsL3(), aStrNew() <span class="kw4">As</span> <span class="kw1">String</span>, aSec() <span class="kw4">As</span> <span class="kw1">Long</span>, aL3(0 <span class="kw3">To</span> 3) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> L_1(0 <span class="kw3">To</span> 3) <span class="kw4">As</span> <span class="kw1">Long</span>, L_2(0 <span class="kw3">To</span> 3) <span class="kw4">As</span> <span class="kw1">Long</span>, L_3(0 <span class="kw3">To</span> 3) <span class="kw4">As</span> <span class="kw1">Long</span>, L_4(0 <span class="kw3">To</span> 3) <span class="kw4">As</span> <span class="kw1">Long</span>, L_5(0 <span class="kw3">To</span> 3) <span class="kw4">As</span> <span class="kw1">Long</span>, L_6(0 <span class="kw3">To</span> 3) <span class="kw4">As</span> <span class="kw1">Long</span>, L_7(0 <span class="kw3">To</span> 3) <span class="kw4">As</span> <span class="kw1">Long</span>, L_8(0 <span class="kw3">To</span> 3) <span class="kw4">As</span> <span class="kw1">Long</span>
<span class="kw4">Dim</span> tx$, t!, n&amp;, c&amp;
<span class="kw4">Dim</span> sec&amp;, a_D&amp;, a_M&amp;, a_S&amp;
Const cyc&amp; = 1000000
&nbsp;
tx = <span class="st0">&quot;Get Arrays(Timer)&quot;</span>: Debug.<span class="kw4">Print</span> tx &amp; <span class="kw1">String</span>$(100 - Len(tx), <span class="st0">&quot;=&quot;</span>),
&nbsp;
t = Timer
&nbsp; &nbsp; aStr = Array(<span class="st0">&quot;1°1'1''&quot;</span>, <span class="st0">&quot;-10°11'12''&quot;</span>, <span class="st0">&quot;-10°1'&quot;</span>, <span class="st0">&quot;1°111''&quot;</span>, <span class="st0">&quot;12'1''&quot;</span>, <span class="st0">&quot;12°&quot;</span>, <span class="st0">&quot;-15'&quot;</span>, <span class="st0">&quot;10''&quot;</span>) &nbsp; &nbsp;<span class="co1">' * cyc = 8 mln Operations</span>
&nbsp;
&nbsp; &nbsp; <span class="kw4">ReDim</span> aArrsL3(<span class="kw4">UBound</span>(aStr))
&nbsp; &nbsp; <span class="kw4">ReDim</span> aStrNew(<span class="kw4">UBound</span>(aStr))
&nbsp; &nbsp; <span class="kw4">ReDim</span> aSec(<span class="kw4">UBound</span>(aStr))
&nbsp; &nbsp; 
&nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aStr)
&nbsp; &nbsp; &nbsp; &nbsp; Degrees_Str_ToArrL3 aStr(n), aL3
&nbsp; &nbsp; &nbsp; &nbsp; aArrsL3(n) = aL3
&nbsp; &nbsp; &nbsp; &nbsp; aSec(n) = aL3(0)
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">For</span> c = 0 <span class="kw3">To</span> 3
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Select</span> <span class="kw3">Case</span> n
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Case</span> 1: L_1(0) = aL3(0): L_1(1) = aL3(1): L_1(2) = aL3(2): L_1(3) = aL3(3)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Case</span> 2: L_2(0) = aL3(0): L_2(1) = aL3(1): L_2(2) = aL3(2): L_2(3) = aL3(3)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Case</span> 3: L_3(0) = aL3(0): L_3(1) = aL3(1): L_3(2) = aL3(2): L_3(3) = aL3(3)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Case</span> 4: L_4(0) = aL3(0): L_4(1) = aL3(1): L_4(2) = aL3(2): L_4(3) = aL3(3)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Case</span> 5: L_5(0) = aL3(0): L_5(1) = aL3(1): L_5(2) = aL3(2): L_5(3) = aL3(3)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Case</span> 6: L_6(0) = aL3(0): L_6(1) = aL3(1): L_6(2) = aL3(2): L_6(3) = aL3(3)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Case</span> 7: L_7(0) = aL3(0): L_7(1) = aL3(1): L_7(2) = aL3(2): L_7(3) = aL3(3)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Case</span> 8: L_8(0) = aL3(0): L_8(1) = aL3(1): L_8(2) = aL3(2): L_8(3) = aL3(3)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">Select</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Next</span> c
&nbsp; &nbsp; <span class="kw3">Next</span> n
Debug.<span class="kw4">Print</span> Round(Timer - t, 2) <span class="co1">' 0.0</span>
&nbsp;
&nbsp;
<span class="co1">'================================================</span>
tx = <span class="st0">&quot;String Check(Timer)&quot;</span>: Debug.<span class="kw4">Print</span> tx &amp; <span class="kw1">String</span>$(100 - Len(tx), <span class="st0">&quot;=&quot;</span>),
&nbsp;
t = Timer
&nbsp; &nbsp; <span class="kw3">For</span> c = 1 <span class="kw3">To</span> cyc
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aStr)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> <span class="kw3">Not</span> Degrees_Str_IsCorrect(aStr(n), , <span class="kw5">True</span>) <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Sub</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Next</span> n
&nbsp; &nbsp; <span class="kw3">Next</span> c
Debug.<span class="kw4">Print</span> Round(Timer - t, 2) <span class="co1">' 4.5</span>
&nbsp;
&nbsp;
<span class="co1">'================================================</span>
tx = <span class="st0">&quot;String To ArrArrL3(Timer)&quot;</span>: Debug.<span class="kw4">Print</span> tx &amp; <span class="kw1">String</span>$(100 - Len(tx), <span class="st0">&quot;=&quot;</span>),
&nbsp;
t = Timer
&nbsp; &nbsp; <span class="kw3">For</span> c = 1 <span class="kw3">To</span> cyc
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aStr)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> <span class="kw3">Not</span> Degrees_Str_ToArrL3(aStr(n), aL3, , <span class="kw5">True</span>) <span class="kw3">Then</span> <span class="kw2">Exit</span> <span class="kw2">Sub</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Next</span> n
&nbsp; &nbsp; <span class="kw3">Next</span> c
Debug.<span class="kw4">Print</span> Round(Timer - t, 2) <span class="co1">' 5.3</span>
<span class="co1">'------------------------------------------------</span>
&nbsp;
tx = <span class="st0">&quot;String To ArrArrL3(Check)&quot;</span>: Debug.<span class="kw4">Print</span> tx &amp; <span class="kw1">String</span>$(100 - Len(tx), <span class="st0">&quot;-&quot;</span>)
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aStr)
&nbsp; &nbsp; Degrees_Str_ToArrL3 aStr(n), aL3
&nbsp;
&nbsp; &nbsp; <span class="kw3">For</span> c = 0 <span class="kw3">To</span> <span class="kw4">UBound</span>(aL3)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> aL3(c) &lt;&gt; aArrsL3(n)(c) <span class="kw3">Then</span> Debug.<span class="kw4">Print</span> n, c, aL3(c) &amp; <span class="st0">&quot;&lt;&gt;&quot;</span> &amp; aArrsL3(n)(c)
&nbsp; &nbsp; <span class="kw3">Next</span> c
<span class="kw3">Next</span> n
&nbsp;
&nbsp;
<span class="co1">'================================================</span>
tx = <span class="st0">&quot;Second To ArrL3(Timer)&quot;</span>: Debug.<span class="kw4">Print</span> tx &amp; <span class="kw1">String</span>$(100 - Len(tx), <span class="st0">&quot;=&quot;</span>),
&nbsp;
t = Timer
&nbsp; &nbsp; <span class="kw3">For</span> c = 1 <span class="kw3">To</span> cyc
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aSec)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Degrees_Sec_ToArrL3 aSec(n), aL3
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Next</span> n
&nbsp; &nbsp; <span class="kw3">Next</span> c
Debug.<span class="kw4">Print</span> Round(Timer - t, 2) <span class="co1">' 1.0</span>
&nbsp;
<span class="co1">'------------------------------------------------</span>
tx = <span class="st0">&quot;Second To ArrL3(Check)&quot;</span>: Debug.<span class="kw4">Print</span> tx &amp; <span class="kw1">String</span>$(100 - Len(tx), <span class="st0">&quot;-&quot;</span>)
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aSec)
&nbsp; &nbsp; Degrees_Sec_ToArrL3 aSec(n), aL3
&nbsp;
&nbsp; &nbsp; <span class="kw3">For</span> c = 0 <span class="kw3">To</span> <span class="kw4">UBound</span>(aL3)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> aL3(c) &lt;&gt; aArrsL3(n)(c) <span class="kw3">Then</span> Debug.<span class="kw4">Print</span> n, c, aL3(c) &amp; <span class="st0">&quot;&lt;&gt;&quot;</span> &amp; aArrsL3(n)(c) <span class="co1">' 1&lt;&gt;0 And 51&lt;&gt;111 because &quot;1°111''&quot; = &quot;1°0'111''&quot; transformed to &quot;1°1'51''&quot;</span>
 &nbsp; &nbsp;<span class="kw3">Next</span> c
<span class="kw3">Next</span> n
&nbsp;
&nbsp;
<span class="co1">'================================================</span>
tx = <span class="st0">&quot;ArrL3 To String(Timer)&quot;</span>: Debug.<span class="kw4">Print</span> tx &amp; <span class="kw1">String</span>$(100 - Len(tx), <span class="st0">&quot;=&quot;</span>),
&nbsp;
t = Timer
&nbsp; &nbsp; <span class="kw3">For</span> c = 1 <span class="kw3">To</span> cyc
&nbsp; &nbsp; &nbsp; &nbsp; aStrNew(1) = Degrees_ArrL3_ToStr(L_1, <span class="kw5">True</span>)
&nbsp; &nbsp; &nbsp; &nbsp; aStrNew(2) = Degrees_ArrL3_ToStr(L_2, <span class="kw5">True</span>)
&nbsp; &nbsp; &nbsp; &nbsp; aStrNew(3) = Degrees_ArrL3_ToStr(L_3, <span class="kw5">True</span>)
&nbsp; &nbsp; &nbsp; &nbsp; aStrNew(4) = Degrees_ArrL3_ToStr(L_4, <span class="kw5">True</span>)
&nbsp; &nbsp; &nbsp; &nbsp; aStrNew(5) = Degrees_ArrL3_ToStr(L_5, <span class="kw5">True</span>)
&nbsp; &nbsp; &nbsp; &nbsp; aStrNew(6) = Degrees_ArrL3_ToStr(L_6, <span class="kw5">True</span>)
&nbsp; &nbsp; &nbsp; &nbsp; aStrNew(7) = Degrees_ArrL3_ToStr(L_7, <span class="kw5">True</span>)
&nbsp; &nbsp; &nbsp; &nbsp; aStrNew(8) = Degrees_ArrL3_ToStr(L_8, <span class="kw5">True</span>)
&nbsp; &nbsp; <span class="kw3">Next</span> c
Debug.<span class="kw4">Print</span> Round(Timer - t, 2) <span class="co1">' 4.2</span>
&nbsp;
<span class="co1">'------------------------------------------------</span>
tx = <span class="st0">&quot;ArrL3 To String(Check)&quot;</span>: Debug.<span class="kw4">Print</span> tx &amp; <span class="kw1">String</span>$(100 - Len(tx), <span class="st0">&quot;-&quot;</span>)
&nbsp;
<span class="kw3">For</span> n = 1 <span class="kw3">To</span> <span class="kw4">UBound</span>(aStrNew)
&nbsp; &nbsp; Debug.<span class="kw4">Print</span> n, aStr(n) &amp; <span class="st0">&quot;&lt;&gt;&quot;</span> &amp; aStrNew(n)
&nbsp; &nbsp; <span class="kw3">If</span> aStr(n) &lt;&gt; aStrNew(n) <span class="kw3">Then</span> Debug.<span class="kw4">Print</span> n, aStr(n) &amp; <span class="st0">&quot;&lt;&gt;&quot;</span> &amp; aStrNew(n) <span class="co1">' 1&lt;&gt;0 And 51&lt;&gt;111 because &quot;1°111''&quot; = &quot;1°0'111''&quot; transformed to &quot;1°1'51''&quot;</span>
<span class="kw3">Next</span> n
<span class="kw3">End</span> <span class="kw2">Sub</span>
'==================================================================================================</pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
			   <div class="spoiler-wrap">
				   <div class="spoiler-head folded clickable">Модуль «Work»</div>
				   <div class="spoiler-body">
					   <div class="codeblock"><table class="vb"><thead><tr><td colspan="2" id="796570782"  class="head">Visual Basic</td></tr></thead><tbody><tr class="li1"><td><div id="796570782" style="height: 350px" class="codeframe"><table><tr class="li1"><td class="ln" style="padding: 0px 10px 0px 5px;"><pre class="de1">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
</pre></td><td class="de1"><pre class="de1"><span class="kw2">Option</span> Base 1
<span class="kw2">Option</span> <span class="kw2">Explicit</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> Degrees_Deg_FixNeg(d&amp;) <span class="kw4">As</span> <span class="kw1">Long</span>
&nbsp; &nbsp; Degrees_Deg_FixNeg = 360 + d
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> Degrees_Deg_FixBig(d&amp;) <span class="kw4">As</span> <span class="kw1">Long</span>
&nbsp; &nbsp; Degrees_Deg_FixBig = d <span class="kw4">Mod</span> 360
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> Degrees_Str_IsCorrect(v, <span class="kw4">Optional</span> fMsgTrue <span class="kw4">As</span> <span class="kw1">Boolean</span>, <span class="kw4">Optional</span> fMsgFalse <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Boolean</span>
<span class="kw4">Dim</span> tx$
<span class="kw4">Static</span> st&amp;, RE <span class="kw4">As</span> RegExp
&nbsp; &nbsp; <span class="kw3">If</span> st = 0 <span class="kw3">Then</span> st = 1: <span class="kw4">Set</span> RE = <span class="kw2">New</span> RegExp: RE.Pattern = <span class="st0">&quot;^\d+°\d+'\d+''$|^\d+°\d+'$|^\d+°\d+''$|^\d+'\d+''$|^\d+°$|^\d+'$|^\d+''$&quot;</span>
&nbsp; &nbsp; <span class="kw3">If</span> AscW(v) = 45 <span class="kw3">Then</span> tx = Right$(v, Len(v) - 1) <span class="kw3">Else</span> tx = v
&nbsp; &nbsp; Degrees_Str_IsCorrect = RE.Test(tx)
&nbsp;
&nbsp; &nbsp; <span class="kw3">If</span> <span class="kw3">Not</span> Degrees_Str_IsCorrect <span class="kw3">Then</span> <span class="kw3">GoTo</span> no
&nbsp; &nbsp; <span class="kw3">If</span> fMsgTrue <span class="kw3">Then</span> MsgBox <span class="st0">&quot;String «&quot;</span> &amp; v &amp; <span class="st0">&quot;» is a Degree!&quot;</span>, vbInformation, <span class="st0">&quot;Degrees_Str_IsCorrect&quot;</span>: <span class="kw2">Exit</span> <span class="kw2">Function</span> <span class="kw3">Else</span> <span class="kw2">Exit</span> <span class="kw2">Function</span>
no: <span class="kw3">If</span> fMsgFalse <span class="kw3">Then</span> MsgBox <span class="st0">&quot;String «&quot;</span> &amp; v &amp; <span class="st0">&quot;» is NOT a Degree!&quot;</span>, vbCritical, <span class="st0">&quot;Degrees_Str_IsCorrect&quot;</span>
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="co1">' Transform String like 3°4'3'' to Array 0 To 3: LongInSec, Degreeses, Minutes, Seconds</span>
<span class="kw2">Function</span> Degrees_Str_ToArrL3(<span class="kw4">ByVal</span> v$, aL3() <span class="kw4">As</span> <span class="kw1">Long</span>, <span class="kw4">Optional</span> fMsgTrue <span class="kw4">As</span> <span class="kw1">Boolean</span>, <span class="kw4">Optional</span> fMsgFalse <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">Boolean</span>
<span class="kw4">Dim</span> z&amp;, d&amp;, m&amp;, s&amp;
&nbsp;
<span class="kw3">If</span> AscW(v) = 45 <span class="kw3">Then</span>
&nbsp; &nbsp; z = -1: v = Right$(v, Len(v) - 1)
<span class="kw3">Else</span>
&nbsp; &nbsp; z = 1
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
d = InStr(v, <span class="st0">&quot;°&quot;</span>)
s = InStrRev(v, <span class="st0">&quot;''&quot;</span>)
m = InStr(d + 1, v, <span class="st0">&quot;'&quot;</span>): <span class="kw3">If</span> m = s <span class="kw3">Then</span> m = 0
<span class="kw4">On</span> <span class="kw4">Error</span> <span class="kw3">GoTo</span> ex
&nbsp;
<span class="kw3">If</span> d <span class="kw3">Then</span>
&nbsp; &nbsp; <span class="kw3">If</span> m <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> s <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(1) = Left$(v, d - 1)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(2) = Mid$(v, d + 1, m - d - 1)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(3) = Mid$(v, m + 1, s - m - 1)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(1) = Left$(v, d - 1)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(2) = Mid$(v, d + 1, m - d - 1)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(3) = 0
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
&nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> s <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(1) = Left$(v, d - 1)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(2) = 0
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(3) = Mid$(v, d + 1, s - d - 1)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(1) = Left$(v, d - 1)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(2) = 0
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(3) = 0
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
&nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
<span class="kw3">Else</span>
&nbsp; &nbsp; <span class="kw3">If</span> m <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> s <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(1) = 0
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(2) = Left$(v, m - 1)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(3) = Mid$(v, m + 1, s - m - 1)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(1) = 0
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(2) = Left$(v, m - 1)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(3) = 0
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
&nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> s <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(1) = 0
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(2) = 0
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aL3(3) = Left$(v, s - 1)
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">Stop</span>: <span class="kw3">End</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
&nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
aL3(0) = z * (3600 * aL3(1) + 60 * aL3(2) + aL3(3))
&nbsp;
<span class="kw3">If</span> fMsgTrue <span class="kw3">Then</span> MsgBox <span class="st0">&quot;String «&quot;</span> &amp; v &amp; <span class="st0">&quot;» is a Degree!&quot;</span>, vbInformation, <span class="st0">&quot;Degrees_Str_ToArrL3&quot;</span>
Degrees_Str_ToArrL3 = <span class="kw5">True</span>: <span class="kw2">Exit</span> <span class="kw2">Function</span>
&nbsp;
ex: <span class="kw3">If</span> fMsgFalse <span class="kw3">Then</span> MsgBox <span class="st0">&quot;String «&quot;</span> &amp; v &amp; <span class="st0">&quot;» is NOT a Degree!&quot;</span>, vbCritical, <span class="st0">&quot;Degrees_Str_ToArrL3&quot;</span>
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> Degrees_Sec_ToArrL3(<span class="kw4">ByVal</span> sec&amp;, aL3() <span class="kw4">As</span> <span class="kw1">Long</span>) <span class="kw4">As</span> <span class="kw1">Boolean</span>
&nbsp;
aL3(0) = sec
sec = Abs(sec)
&nbsp;
aL3(1) = sec \ 3600
aL3(2) = (sec - 3600 * aL3(1)) \ 60
aL3(3) = sec - 60 * aL3(2) - 3600 * aL3(1)
&nbsp;
Degrees_Sec_ToArrL3 = <span class="kw5">True</span>
<span class="kw3">End</span> <span class="kw2">Function</span>
<span class="co1">'==================================================================================================</span>
<span class="kw2">Function</span> Degrees_ArrL3_ToStr(aL3() <span class="kw4">As</span> <span class="kw1">Long</span>, <span class="kw4">Optional</span> fSkipZeros <span class="kw4">As</span> <span class="kw1">Boolean</span>) <span class="kw4">As</span> <span class="kw1">String</span>
&nbsp;
<span class="kw3">If</span> fSkipZeros <span class="kw3">Then</span>
&nbsp; &nbsp; <span class="kw3">If</span> aL3(1) <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> aL3(2) <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> aL3(3) <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Degrees_ArrL3_ToStr = aL3(1) &amp; <span class="st0">&quot;°&quot;</span> &amp; aL3(2) &amp; <span class="st0">&quot;'&quot;</span> &amp; aL3(3) &amp; <span class="st0">&quot;''&quot;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Degrees_ArrL3_ToStr = aL3(1) &amp; <span class="st0">&quot;°&quot;</span> &amp; aL3(2) &amp; <span class="st0">&quot;'&quot;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> aL3(3) <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Degrees_ArrL3_ToStr = aL3(1) &amp; <span class="st0">&quot;°&quot;</span> &amp; aL3(3) &amp; <span class="st0">&quot;''&quot;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Degrees_ArrL3_ToStr = aL3(1) &amp; <span class="st0">&quot;°&quot;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
&nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> aL3(2) <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> aL3(3) <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Degrees_ArrL3_ToStr = aL3(2) &amp; <span class="st0">&quot;'&quot;</span> &amp; aL3(3) &amp; <span class="st0">&quot;''&quot;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Degrees_ArrL3_ToStr = aL3(2) &amp; <span class="st0">&quot;'&quot;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">If</span> aL3(3) <span class="kw3">Then</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Degrees_ArrL3_ToStr = aL3(3) &amp; <span class="st0">&quot;''&quot;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Else</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Degrees_ArrL3_ToStr = CVErr(xlErrNA)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
&nbsp; &nbsp; <span class="kw3">End</span> <span class="kw3">If</span>
<span class="kw3">Else</span>
&nbsp; &nbsp; Degrees_ArrL3_ToStr = aL3(1) &amp; <span class="st0">&quot;°&quot;</span> &amp; aL3(2) &amp; <span class="st0">&quot;'&quot;</span> &amp; aL3(3) &amp; <span class="st0">&quot;''&quot;</span>
<span class="kw3">End</span> <span class="kw3">If</span>
&nbsp;
<span class="kw3">If</span> aL3(0) &lt; 0 <span class="kw3">Then</span> Degrees_ArrL3_ToStr = <span class="st0">&quot;-&quot;</span> &amp; Degrees_ArrL3_ToStr
<span class="kw3">End</span> <span class="kw2">Function</span>
'==================================================================================================</pre></td></tr></table></div></td></tr></tbody></table></div>
				   </div>
			   </div>
				   </div>
			   </div></div>

]]></content:encoded>
			<dc:creator>Jack Famous</dc:creator>
			<guid isPermaLink="true">https://www.cyberforum.ru/blogs/1808109/7801.html</guid>
		</item>
	</channel>
</rss>
