-
Notifications
You must be signed in to change notification settings - Fork 7
/
help_use_variables_light.html
669 lines (594 loc) · 27.6 KB
/
help_use_variables_light.html
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
<!DOCTYPE HTML>
<html><head><meta charset="utf-8">
<title>MultiReplace Use Variables Option</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
/* Dark Mode Base Styles */
body.dark-mode { background: #121212; color: #ccc; }
/* Header and Footer Styles */
body.dark-mode header,
body.dark-mode footer { background: #1e1e1e; color: #ddd; border-color: #333; }
/* Link Styles */
body.dark-mode a { color: #4ea8de; }
body.dark-mode a:link { color: #89b4ff; }
body.dark-mode a:visited { color: #89b4ff; }
/* Navigation Link Styles in Dark Mode */
body.dark-mode nav.pagenav {
background-color: #333;
padding: 10px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
margin-bottom: 20px;
}
body.dark-mode nav.pagenav a { color: #89b4ff; }
body.dark-mode nav.pagenav a:visited { color: #89b4ff; }
body.dark-mode nav.pagenav a:hover { text-decoration: underline; }
/* Main Content and Article Styling */
body.dark-mode main,
body.dark-mode article { background: #242424; }
/* Footer Links */
body.dark-mode footer a[rel=license],
body.dark-mode footer a[rel=license] img { color: #888; }
/* Text Elements */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode p { color: #e0e0e0; }
/* Interactive Elements */
body.dark-mode #fontdown,
body.dark-mode #fontup { background: #333; color: #fff; }
body.dark-mode #fontdown:hover,
body.dark-mode #fontup:hover { background: #444; color: #eee; }
/* Additional UI Components */
body.dark-mode main article section { background: #333; border-color: #444; }
body.dark-mode main article section.note { background: #2b2b2b; color: #ddd; }
/* Table Styling */
body.dark-mode table.optionsTable { background: #333; color: #ddd; }
body.dark-mode table.optionsTable th,
body.dark-mode table.optionsTable td { background: #2b2b2b; color: #ccc; }
body.dark-mode table.optionsTable th { background: #333; }
body.dark-mode table.optionsTable tr:hover { background: #3a3a3a; }
/* Miscellaneous Adjustments */
body.dark-mode span.mnemonic { background: #4ea8de; color: #121212; }
body.dark-mode ul, body.dark-mode li { color: #ddd; }
/* Dark Mode Footer Text Styles */
body.dark-mode #foottext { flex: 1; margin: 0 1em; text-align: center; color: #ddd; }
body.dark-mode #foottext a { white-space: nowrap; text-decoration: none; color: #4ea8de; }
body.dark-mode #foottext a:hover { text-decoration: underline; color: #62d1c3; }
body.dark-mode #foottext.linklist a:link { color: #89b4ff; }
body.dark-mode #foottext.linklist a:visited { color: #c678dd; }
body.dark-mode code {
font-family: 'Fira Code', 'Consolas', monospace;
color: #abb2bf;
background-color: #282c34;
padding: 6px 8px;
border-radius: 5px;
border: 1px solid #3a3c43;
font-weight: 600;
font-size: 0.9em;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
display: inline-block;
margin: 0 2px;
vertical-align: middle;
line-height: 1.4;
}
/* Base Styles */
html, body {margin: 0; padding: 0; width: 100%; height: 100%;}
body {display: flex; flex-direction: column; font: 1em Calibri, Tahoma, sans-serif;}
header {padding: 0; width: 100%; display: flex; flex-direction: row; justify-content: space-around;}
header {border-style: none none solid none; border-width: 0 0 2px 0;}
header {font-size: min(5vw,10vh,1.75rem); font-weight: bold;}
footer {padding: 4px 0; width: 100%; display: flex; flex-direction: row; align-items: center; font-size: medium;}
footer {border-style: solid none none none; border-width: 2px 0 0 0;}
footer a[rel=license] {padding: 0 8px; text-decoration: none;}
footer a[rel=license] img {border: none;}
#foottext {flex: 1; margin: 0 1em; text-align: center;}
#foottext a {white-space: nowrap; text-decoration: none; color: inherit; }
#foottext a:hover {text-decoration: underline;}
#foottext.linklist a:link {color: #00c;}
#foottext.linklist a:visited {color: #900;}
#fontdown, #fontup {margin: 0 8px; padding: 0; height: 28px; width: 48px; text-align: center; display: none;}
#fontdown, #fontup {color: #000; border: none; border-radius: 15%/20%; cursor: pointer;}
#fontdown, #fontup {background: transparent;}
#fontdown:hover,
#fontup:hover {background: #333; color: #fff;}
#fontdown {font: inherit; font-size: 13px;}
#fontup {font: inherit; font-size: 19px; line-height: 1.0;}
main {flex: 1; overflow: auto;}
article {padding: 0 1em; line-height: 1.4;}
p {margin: 0; padding: 0;}
p + p {margin: .5em 0 0 0; padding: 0;}
h1 {line-height: 1.25; margin: .5em 0 0 0;}
h1 {font-size: 1.5rem; text-align: center; font-weight: bold; font-style: normal; padding: 0;}
h2 {font-size: 1.2rem; text-align: left; font-weight: bold; font-style: normal; padding: 0; margin: 0;}
h3 {font-size: 1rem; text-align: left; font-weight: bold; font-style: normal; padding: 0; margin: 0; }
main a {white-space: nowrap; text-decoration: none;}
main a:link {color: #00c;}
main a:visited {color: #00c;}
main a:hover {text-decoration: underline;}
@media (max-width: 480px) {
main a {white-space: normal;}
#foottext a {white-space: normal;}
}
main article section {border-style: none; border-width: 0; padding: 0 1em .3em 1em; background: #eee;}
main article section {margin: 1.25rem 0 .4rem 0;}
main article section h2 {border-style: none none solid none; border-width: 0 0 1px 0;}
main article section h2 {margin: 0 0 .3em -6px; padding: .2em 0 .2em 6px;}
main article section h3 {margin: .75em 0 .2em 0; padding: .2em 0 .1em 0; line-height: 1.2; }
main article h1+section {margin-top: .75rem;}
main article h1+p {margin-top: .6em;}
main article section+p {margin-top: .75em;}
main article section >
p:first-child {margin-top: .3em;}
main article section.note {font-size: .85em; border-style: solid; border-width: 3px 1px 1px 6px; padding: 0 6px;}
body h1 {margin: 0;}
body .pagenav {font-weight: bold; text-align: left; margin: .5em .5em 0 .5em; line-height: 1.6; background: #eee;}
body .pagenav a {margin: 0 .5em; white-space: nowrap;}
@media (min-width: 640px) {
body main {display: flex; flex-direction: row; padding: 0;}
body .pagenav {padding: .5em 0 0 0; margin: 1.25em 1em .4em;}
body .pagenav {white-space: pre;}
body article {flex: 1; overflow: auto; padding: 0 1em 0 0;}
body h1 {margin-top: .5em;}
}
body #centershortlines ~ article h1 {max-width: calc(32em + 12px);}
body #centershortlines ~ article section {max-width: 48em;}
p.subsub {margin-left: 1.5em;}
table.justAlign {border: none; margin: 0; border-collapse: collapse;}
table.justAlign td {border:none; padding: 0; font: inherit;}
table.justAlign td+td {padding: 0 0 0 1em;}
ul {margin: 0 0 .5em 0;}
ul li {margin: .25em 0;}
span.mnemonic {color: #fff; background: #000; padding: 0 .2em; border-radius: .2em; font-size: .9em; font-weight: bold; display: inline-block;}
body {color: #000; background: #d0d0d0; line-height: 1.4;}
* {border-color: #999;}
#centershortlines {width: calc((100vw - (13.5em + 48em + 2em + 24px)) / 2);}
code {
font-family: 'Fira Code', 'Consolas', monospace;
color: #333;
background-color: #eef2f5;
padding: 6px 8px;
border-radius: 5px;
border: 1px solid #d1d6da;
font-weight: 600;
font-size: 0.9em;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
display: inline-block;
margin: 0 2px;
vertical-align: middle;
line-height: 1.4;
}
table.optionsTable {
border-collapse: separate;
border-spacing: 0;
width: 100%;
margin: 1em auto;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
background: white;
border-radius: 8px;
overflow: hidden;
}
table.optionsTable th,
table.optionsTable td {
padding: .8em 1em;
text-align: left;
vertical-align: middle;
border-bottom: 2px solid #ccc;
box-shadow: inset 0 -1px 0 #ccc;
}
table.optionsTable th {
background-color: #ddd;
color: #333;
font-weight: 600;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
table.optionsTable tr:last-child th,
table.optionsTable tr:last-child td {
border-bottom: none;
}
table.optionsTable tr:hover {
background-color: #ececec;
}
table .optionsTable .group {
background-color: #d0d0d0;
color: #333;
text-align: center;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
nav.pagenav {
background-color: #eee;
padding: 10px;
border-radius: 8px;
margin-bottom: 20px;
}
nav.pagenav {
background-color: #eee;
padding: 5px;
border-radius: 8px;
margin-bottom: 20px;
display: flex;
flex-direction: column;
align-items: flex-start;
}
nav.pagenav a {
color: #00c;
text-decoration: none;
margin: 0;
padding: 2px 0;
}
nav.pagenav a:hover {
text-decoration: underline;
}
nav.pagenav .sub-item {
margin-left: 15px;
font-size: 0.95em;
}
body.dark-mode nav.pagenav {
background-color: #333;
}
body.dark-mode nav.pagenav a {
color: #89b4ff;
}
body.dark-mode nav.pagenav a:hover {
color: #62d1c3;
}
body.dark-mode nav.pagenav .sub-item {
color: #89b4ff;
}
</style>
<script>
var isDarkModeEnabled = false; // Set this variavle to true or false to activate or deactivate DarkMode
function doPageLoad() {
if (document.getElementById("fontdown")) {
document.getElementById("fontdown").style.display = "inline-block";
document.getElementById("fontup").style.display = "inline-block";
if (window.localStorage) {
var n = localStorage.getItem("ColumnsPlusPlusFontSize");
if (!isNaN(n) && n >= 9 && n <= 40) {
document.documentElement.style.fontSize = n + "px";
}
}
}
}
function setFontDown() {
var n = parseFloat(window.getComputedStyle(document.documentElement).fontSize);
if (n > 9) --n;
document.documentElement.style.fontSize = n + "px";
if (window.localStorage) localStorage.setItem("ColumnsPlusPlusFontSize", n);
}
function setFontUp() {
var n = parseFloat(window.getComputedStyle(document.documentElement).fontSize);
if (n < 40) ++n;
document.documentElement.style.fontSize = n + "px";
if (window.localStorage) localStorage.setItem("ColumnsPlusPlusFontSize", n);
}
function checkDarkMode() {
if (isDarkModeEnabled) {
document.body.classList.add('dark-mode');
console.log("Dark Mode On");
} else {
console.log("Dark Mode Off");
}
}
document.addEventListener('DOMContentLoaded', function() {
console.log("Document loaded");
checkDarkMode();
});
</script>
</head>
<body>
<header>MultiReplace: "Use Variables" Feature Guide</header>
<main>
<div id="centershortlines"></div>
<nav class="pagenav">
<a href="#Introduction">Introduction</a>
<a href="#FirstSteps">First Steps</a>
<a href="#Variables">Variables</a>
<a href="#Commands">Commands</a>
<a href="#setstrorcalc" class="sub-item">set()</a>
<a href="#condcondition-trueval-falseval" class="sub-item">cond()</a>
<a href="#initvariable1value1-variable2value2" class="sub-item">init()</a>
<a href="#fmtnnum-maxdecimals-fixeddecimals" class="sub-item">fmtN()</a>
<a href="#Operators">Operators</a>
<a href="#IfThenLogic">If-Then Logic</a>
<a href="#DebugOption">Debug Option</a>
<a href="#FurtherFunctions">Math & String Functions</a>
<a href="#Examples">Examples</a>
</nav>
<article>
<section id=Introduction>
<h2>Introduction</h2>
Activate the <strong>Use Variables</strong> checkbox to employ variables associated with specified strings, allowing for conditional and computational operations within the replacement string. This Dynamic Substitution is compatible with all search settings of Search Mode, Scope, and the other options. The functionality relies on the <a href="https://www.lua.org/" target="_blank">Lua engine</a>.
</section>
<section id=FirstSteps>
<h2>First step</h2>
Utilize either the <a href="#setstrorcalc"><code>set()</code></a> or <a href="#condcondition-trueval-falseval"><code>cond()</code></a> command in 'Replace with:' to channel the output as the replacement string. Only one of these commands should be used at a time.
</section>
<section id=Variables>
<h2>Variables</h2>
<table class="optionsTable">
<tr>
<th>Variable</th>
<th>Description</th>
</tr>
<tr>
<td><strong>CNT</strong></td>
<td>Count of the detected string.</td>
</tr>
<tr>
<td><strong>LINE</strong></td>
<td>Line number where the string is found.</td>
</tr>
<tr>
<td><strong>APOS</strong></td>
<td>Absolute character position in the document.</td>
</tr>
<tr>
<td><strong>LPOS</strong></td>
<td>Relative line position.</td>
</tr>
<tr>
<td><strong>LCNT</strong></td>
<td>Count of the detected string within the line.</td>
</tr>
<tr>
<td><strong>COL</strong></td>
<td>Column number where the string was found (CSV-Scope option selected).</td>
</tr>
<tr>
<td><strong>MATCH</strong></td>
<td>Contains the text of the detected string, in contrast to <code>CAP</code> variables which correspond to capture groups in regex patterns.</td>
</tr>
<tr>
<td><strong>CAP1</strong>, <strong>CAP2</strong>,...</td>
<td>These variables are equivalents to regex capture groups, designed for use in the 'Use Variables' environment. They are specifically suited for calculations and conditional operations within this environment. Although their counterparts ($1, $2, ...) cannot be used here.</td>
</tr>
<tr>
<td colspan="2"><strong>Decimal Separator:</strong> When <code>MATCH</code> and <code>CAP</code> variables are used to read numerical values for further calculations, both dot (.) and comma (,) can serve as decimal separators. However, these variables do not support the use of thousands separators.</td>
</tr>
</table>
</section>
<section id=Commands>
<h2>Commands</h2>
<h3 id="setstrorcalc">set(strOrCalc)</h3>
<p>Outputs strings or numbers directly.</p>
<table class="optionsTable">
<tr>
<th>Example</th>
<th>Result (assuming LINE = 5, CNT = 3)</th>
</tr>
<tr>
<td><code>set("replaceString"..CNT)</code></td>
<td>"replaceString3"</td>
</tr>
<tr>
<td><code>set(LINE+5)</code></td>
<td>"10"</td>
</tr>
</table>
<h3 id="condcondition-trueval-falseval">cond(condition, trueVal, [falseVal])</h3>
<p>Implements if-then-else logic, or if-then if falseVal is omitted.</p>
<table class="optionsTable">
<tr>
<th>Example</th>
<th>Result (assuming LINE = 5)</th>
</tr>
<tr>
<td><code>cond(LINE<=5 or LINE>=9, "edge", "center")</code></td>
<td>"edge"</td>
</tr>
<tr>
<td><code>cond(LINE<3, "Modify this line")</code></td>
<td>(Original text remains unchanged)</td>
</tr>
<tr>
<td><code>cond(LINE<10, cond(LINE<5, cond(LINE>2, "3-4", "0-2"), "5-9") , "10+")</code></td>
<td>"5-9" (Nested condition)</td>
</tr>
</table>
<h3 id="initvariable1value1-variable2value2">init({Variable1=Value1, Variable2=Value2, ...})</h3>
Initializes custom variables for use in various commands, extending beyond standard variables like CNT, MATCH, CAP1. These variables can carry the status of previous find-and-replace operations to subsequent ones.<p>
<p>
Custom variables maintain their values throughout a single Replace-All or within the list of multiple Replace operations. So they can transfer values from one list entry to the following ones. They reset at the start of each new document in 'Replace All in All Open Documents'.
</p>
<p>
<strong>Note:</strong> An empty Find string can be used to set variables for the entire Find and Replace list without linking it to a specific Find action. This string will not match any text but is triggered at the start of the the 'Replace' or 'Replace All' process when 'Use List' is enabled, allowing the Replace field to initialize commands like init() for the entire operation. The position of the entry in the list is irrelevant.
</p>
<table class="optionsTable">
<tr>
<th>Find:</th>
<th>Replace:</th>
<th>Before</th>
<th>After</th>
</tr>
<tr>
<td><code>(\d+)</code></td>
<td><code>init({COL2=0,COL4=0}); cond(LCNT==4, COL2+COL4); if COL==2 then COL2=CAP1 end; if COL==4 then COL4=CAP1 end;</code></td>
<td>1,20,text,2,0<br>2,30,text,3,0<br>3,40,text,4,0</td>
<td>1,20,text,2,22.0<br>2,30,text,3,33.0<br>3,40,text,4,44.0</td>
</tr>
<tr>
<td><code>\d{2}-[A-Z]</code></td>
<td><code>init({MATCH_PREV=''}); cond(LCNT==1,'Moved', MATCH_PREV); MATCH_PREV=MATCH;</code></td>
<td>12-P,00-A<br>65-S,00-A<br>43-V,00-A</td>
<td>Moved,12-P<br>Moved,65-S<br>Moved,43-V</td>
</tr>
</table>
<h3 id="fmtnnum-maxdecimals-fixeddecimals">fmtN(num, maxDecimals, fixedDecimals)</h3>
<p>Formats numbers based on precision (maxDecimals) and whether the number of decimals is fixed (fixedDecimals being true or false).</p>
<p><strong>Note</strong>: The <code>fmtN</code> command can exclusively be used within the <code>set</code> and <code>cond</code> commands.</p>
<table class="optionsTable">
<tr>
<th>Example</th>
<th>Result</th>
</tr>
<tr>
<td><code>set(fmtN(5.73652, 2, true))</code></td>
<td>"5.74"</td>
</tr>
<tr>
<td><code>set(fmtN(5.0, 2, true))</code></td>
<td>"5.00"</td>
</tr>
<tr>
<td><code>set(fmtN(5.73652, 4, false))</code></td>
<td>"5.7365"</td>
</tr>
<tr>
<td><code>set(fmtN(5.0, 4, false))</code></td>
<td>"5"</td>
</tr>
</table>
</section>
<section id=Operators>
<h2>Operators</h2>
<table class="optionsTable">
<tr>
<th>Type</th>
<th>Operators</th>
<th>Example</th>
</tr>
<tr>
<td>Concatenation</td>
<td><code>..</code></td>
<td><code>set("Found "..CNT)</code></td>
</tr>
<tr>
<td>Arithmetic</td>
<td><code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>, <code>^</code>, <code>%</code></td>
<td><code>set(CNT * 2)</code></td>
</tr>
<tr>
<td>Relational</td>
<td><code>==</code>, <code>~=</code>, <code><</code>, <code>></code>, <code><=</code>, <code>>=</code></td>
<td><code>cond(LINE == 1, "First", "Not first")</code></td>
</tr>
<tr>
<td>Logical</td>
<td><code>and</code>, <code>or</code>, <code>not</code></td>
<td><code>cond(LINE > 5 and CNT < 10, "Midrange", "Other")</code></td>
</tr>
</table>
</section>
<section id=IfThenLogic>
<h2>If-Then Logic</h2>
<p>
If-then logic is integral for dynamic replacements, allowing users to set custom variables based on specific conditions. This enhances the versatility of find-and-replace operations.
</p>
<p>
<strong>Note</strong>: Do not embed <code>cond()</code>, <code>set()</code>, or <code>init()</code> within <code>if</code> statements; <code>if</code> statements are exclusively for adjusting custom variables.
</p>
<h3>Syntax Combinations</h3>
<ul>
<li><code>if condition then ... end</code></li>
<li><code>if condition then ... else ... end</code></li>
<li><code>if condition then ... elseif another_condition then ... end</code></li>
<li><code>if condition then ... elseif another_condition then ... else ... end</code></li>
</ul>
<h3>Example</h3>
<p>
This example shows how to use <code>if</code> statements with <code>cond()</code> to manage variables based on conditions:
</p>
<code>init({MVAR=""}); if CAP2~=nil then MVAR=MVAR..CAP2 end; cond(string.sub(CAP1,1,1)~="#", MVAR); if CAP2~=nil then MVAR=string.sub(CAP1,4,-1) end</code>
</section>
<section id=DebugOption>
<h2>DEBUG option</h2>
<p>
The <code>DEBUG</code> option lets you inspect global variables during replacements. When enabled, it opens a message box displaying the current values of all global variables for each replacement hit, requiring confirmation to proceed to the next match. Initialize the <code>DEBUG</code> option in your replacement string to enable it.
</p>
<h3>Example</h3>
<table class="optionsTable">
<tr>
<th>Find:</th>
<th>Replace with:</th>
</tr>
<tr>
<td><code>(\d+)</code></td>
<td><code>init({DEBUG=true}); set("Number: "..CAP1)</code></td>
</tr>
</table>
</section>
<section id=FurtherFunctions>
<h2>Math & String Functions</h2>
<p>MultiReplace uses the <a href="https://www.lua.org/" target="_blank">Lua engine</a>, allowing for Lua math operations and string methods. Refer to <a href="https://www.lua.org/manual/5.4/manual.html#6.4" target="_blank">Lua String Manipulation</a> and <a href="https://www.lua.org/manual/5.4/manual.html#6.6" target="_blank">Lua Mathematical Functions</a> for more information.</p>
</section>
<section id=Examples>
<h2>Examples</h2>
<table class="optionsTable">
<tr>
<th>Find in:</th>
<th>Replace with:</th>
<th>Description/Expected Output</th>
<th>Regex</th>
<th>Scope CSV</th>
</tr>
<tr>
<td><code>;</code></td>
<td><code>cond(LCNT==5,";Column5;")</code></td>
<td>Adds a 5th Column for each line into a `;` delimited file.</td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td><code>key</code></td>
<td><code>set("key"..CNT)</code></td>
<td>Enumerates key values by appending the count of detected strings. E.g., key1, key2, key3, etc.</td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td><code>(\d+)</code></td>
<td><code>set(CAP1.."€ The VAT is: ".. (CAP1 * 0.15).."€ Total with VAT: ".. (CAP1 + (CAP1 * 0.15)).."€")</code></td>
<td>Finds a number and calculates the VAT at 15%, then displays the original amount, the VAT, and the total amount. E.g., `50` becomes `50€ The VAT is: 7.5€ Total with VAT: 57.5€`</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td><code>---</code></td>
<td><code>cond(COL==1 and LINE<3, "0-2" , cond(COL==2 and LINE>2 and LINE<5, "3-4" , cond(COL==3 and LINE>=5 and LINE<10, "5-9" , cond(COL==4 and LINE>=10, "10+"))))</code></td>
<td>Replaces `---` with a specific range based on the `COL` and `LINE` values. E.g., `3-4` in column 2 of lines 3-4, and `5-9` in column 3 of lines 5-9 assuming `---` is found in all lines and columns.</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td><code>(\d+)\.(\d+)\.(\d+)</code></td>
<td><code>cond(CAP1 > 0 and CAP2 == 0 and CAP3 == 0, MATCH, cond(CAP2 > 0 and CAP3 == 0, " " .. MATCH, " " .. MATCH))</code></td>
<td>Alters the spacing based on the hierarchy of the version numbers, aligning lower hierarchies with spaces as needed. E.g., `1.0.0` remains `1.0.0`, `1.2.0` becomes ` 1.2.0`, indicating a second-level version change.</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td><code>(\d+)</code></td>
<td><code>set(CAP1 * 2)</code></td>
<td>Doubles the matched number. E.g., `100` becomes `200`.</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td><code>;</code></td>
<td><code>cond(LCNT == 1, string.rep(" ", 20- (LPOS))..";")</code></td>
<td>Inserts spaces before the semicolon to align it to the 20th character position if it's the first occurrence.</td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td><code>-</code></td>
<td><code>cond(LINE == math.floor(10.5 + 6.25 * math.sin((2 * math.pi * LPOS) / 50)), "*", " ")</code></td>
<td>Draws a sine wave across a canvas of '-' characters spanning at least 20 lines and 80 characters per line.</td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td><code>^(.*)$</code></td>
<td><code>init({MATCH_PREV=1}); cond(MATCH == MATCH_PREV, ''); MATCH_PREV=MATCH;</code></td>
<td>Removes duplicate lines, keeping the first occurrence of each line. Matches an entire line and uses MATCH_PREV to identify and remove consecutive duplicates.</td>
<td>Yes</td>
<td>No</td>
</tr>
</table>
</section>
</article>
</main><footer id=footer><div id=foottext class=linklist>
<a href="https://notepad-plus-plus.org/">Notepad++</a> • <a href="https://github.com/daddel80/notepadpp-multireplace">MultiReplace on GitHub</a>
</div><button type=button id=fontdown onclick="setFontDown();">Txt-</button><button type=button id=fontup onclick="setFontUp();">Txt+</button>
</footer></body></html>