-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathReference-manual_elementary_str.html
1054 lines (1017 loc) · 50.6 KB
/
Reference-manual_elementary_str.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
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<base href=".">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>str</title>
<link rel="stylesheet" href="assets/css/dark-frontend.css" type="text/css" title="dark">
<link rel="alternate stylesheet" href="assets/css/light-frontend.css" type="text/css" title="light">
<link rel="stylesheet" href="assets/css/bootstrap-toc.min.css" type="text/css">
<link rel="stylesheet" href="assets/css/jquery.mCustomScrollbar.min.css">
<link rel="stylesheet" href="assets/js/search/enable_search.css" type="text/css">
<link rel="stylesheet" href="assets/css/prism-tomorrow.css" type="text/css" title="dark">
<link rel="alternate stylesheet" href="assets/css/prism.css" type="text/css" title="light">
<script src="assets/js/mustache.min.js"></script>
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap.js"></script>
<script src="assets/js/scrollspy.js"></script>
<script src="assets/js/typeahead.jquery.min.js"></script>
<script src="assets/js/search.js"></script>
<script src="assets/js/compare-versions.js"></script>
<script src="assets/js/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="assets/js/bootstrap-toc.min.js"></script>
<script src="assets/js/jquery.touchSwipe.min.js"></script>
<script src="assets/js/anchor.min.js"></script>
<script src="assets/js/tag_filtering.js"></script>
<script src="assets/js/language_switching.js"></script>
<script src="assets/js/styleswitcher.js"></script>
<script src="assets/js/lines_around_headings.js"></script>
<script src="assets/js/prism-core.js"></script>
<script src="assets/js/prism-autoloader.js"></script>
<script src="assets/js/prism_autoloader_path_override.js"></script>
<script src="assets/js/prism-keep-markup.js"></script>
<script src="assets/js/trie.js"></script>
<link rel="icon" type="image/png" href="assets/images/favicon.png">
<link rel="shortcut icon" href="assets/images/favicon.png">
</head>
<body class="no-script
">
<script>
$('body').removeClass('no-script');
</script>
<nav class="navbar navbar-fixed-top navbar-default" id="topnav">
<div class="container-fluid">
<div class="navbar-right">
<a id="toc-toggle">
<span class="glyphicon glyphicon-menu-right"></span>
<span class="glyphicon glyphicon-menu-left"></span>
</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-wrapper" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span title="light mode switch" class="glyphicon glyphicon-sunglasses pull-right" id="lightmode-icon"></span>
<form class="navbar-form pull-right" id="navbar-search-form">
<div class="form-group has-feedback">
<input type="text" class="form-control input-sm" name="search" id="sidenav-lookup-field" placeholder="search" disabled>
<span class="glyphicon glyphicon-search form-control-feedback" id="search-mgn-glass"></span>
</div>
</form>
</div>
<div class="navbar-header">
<a id="sidenav-toggle">
<span class="glyphicon glyphicon-menu-right"></span>
<span class="glyphicon glyphicon-menu-left"></span>
</a>
<a id="home-link" href="index.html" class="hotdoc-navbar-brand">
<img src="assets/images/meson_logo.png" alt="Home">
</a>
</div>
<div class="navbar-collapse collapse" id="navbar-wrapper">
<ul class="nav navbar-nav" id="menu">
<li class="dropdown">
<a class="dropdown-toggle" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Modules <span class="caret"></span>
</a>
<ul class="dropdown-menu" id="modules-menu">
<li>
<a href="CMake-module.html">CMake</a>
</li>
<li>
<a href="Cuda-module.html">CUDA</a>
</li>
<li>
<a href="Dlang-module.html">Dlang</a>
</li>
<li>
<a href="External-Project-module.html">External Project</a>
</li>
<li>
<a href="Fs-module.html">Filesystem</a>
</li>
<li>
<a href="Gnome-module.html">GNOME</a>
</li>
<li>
<a href="Hotdoc-module.html">Hotdoc</a>
</li>
<li>
<a href="i18n-module.html">i18n</a>
</li>
<li>
<a href="Icestorm-module.html">Icestorm</a>
</li>
<li>
<a href="Java-module.html">Java</a>
</li>
<li>
<a href="Keyval-module.html">Keyval</a>
</li>
<li>
<a href="Pkgconfig-module.html">Pkgconfig</a>
</li>
<li>
<a href="Python-3-module.html">Python 3</a>
</li>
<li>
<a href="Python-module.html">Python</a>
</li>
<li>
<a href="Qt4-module.html">Qt4</a>
</li>
<li>
<a href="Qt5-module.html">Qt5</a>
</li>
<li>
<a href="Qt6-module.html">Qt6</a>
</li>
<li>
<a href="Rust-module.html">Rust</a>
</li>
<li>
<a href="Simd-module.html">Simd</a>
</li>
<li>
<a href="SourceSet-module.html">SourceSet</a>
</li>
<li>
<a href="Wayland-module.html">Wayland</a>
</li>
<li>
<a href="Windows-module.html">Windows</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Quick References <span class="caret"></span>
</a>
<ul class="dropdown-menu" id="quick-refs-menu">
<li>
<a href="Reference-manual.html">Functions</a>
</li>
<li>
<a href="Build-options.html">Options</a>
</li>
<li>
<a href="Configuration.html">Configuration</a>
</li>
<li>
<a href="Dependencies.html">Dependencies</a>
</li>
<li>
<a href="Unit-tests.html">Tests</a>
</li>
<li>
<a href="Syntax.html">Syntax</a>
</li>
</ul>
</li>
</ul>
<div class="hidden-xs hidden-sm navbar-text navbar-center">
<p><b>The Meson Build System</b></p>
</div>
</div>
</div>
</nav>
<main>
<div data-extension="core" data-hotdoc-in-toplevel="True" data-hotdoc-project="Meson-documentation" data-hotdoc-ref="Reference-manual_elementary_str.html" class="page_container" id="page-wrapper">
<script src="assets/js/utils.js"></script>
<div class="panel panel-collapse oc-collapsed" id="sidenav" data-hotdoc-role="navigation">
<script src="assets/js/full-width.js"></script>
<div id="sitenav-wrapper">
<iframe src="hotdoc-sitemap.html" id="sitenav-frame"></iframe>
</div>
</div>
<div id="body">
<div id="main">
<div id="page-description" data-hotdoc-role="main">
<h1 id="string-str">String (<code>str</code>)</h1>
<p>All <a href="Syntax.html#strings">strings</a> have the following methods. Strings
are immutable, all operations return their results as a new string.</p>
<h2 id="returned-by">Returned by</h2>
<p>String objects are returned by the following functions and methods:</p>
<ul>
<li><a href="Reference-manual_functions.html#get_option"><ins><code>get_option()</code></ins></a></li>
<li><a href="Reference-manual_functions.html#join_paths"><ins><code>join_paths()</code></ins></a></li>
<li><a href="Reference-manual_elementary_bool.html#boolto_string"><ins><code>bool.to_string()</code></ins></a></li>
<li><a href="Reference-manual_builtin_build_machine.html#build_machinecpu"><ins><code>build_machine.cpu()</code></ins></a></li>
<li><a href="Reference-manual_builtin_build_machine.html#build_machinecpu_family"><ins><code>build_machine.cpu_family()</code></ins></a></li>
<li><a href="Reference-manual_builtin_build_machine.html#build_machineendian"><ins><code>build_machine.endian()</code></ins></a></li>
<li><a href="Reference-manual_builtin_build_machine.html#build_machinekernel"><ins><code>build_machine.kernel()</code></ins></a></li>
<li><a href="Reference-manual_builtin_build_machine.html#build_machinesubsystem"><ins><code>build_machine.subsystem()</code></ins></a></li>
<li><a href="Reference-manual_builtin_build_machine.html#build_machinesystem"><ins><code>build_machine.system()</code></ins></a></li>
<li><a href="Reference-manual_returned_build_tgt.html#build_tgtfull_path"><ins><code>build_tgt.full_path()</code></ins></a></li>
<li><a href="Reference-manual_returned_build_tgt.html#build_tgtname"><ins><code>build_tgt.name()</code></ins></a></li>
<li><a href="Reference-manual_returned_build_tgt.html#build_tgtpath"><ins><code>build_tgt.path()</code></ins></a></li>
<li><a href="Reference-manual_returned_cfg_data.html#cfg_dataget"><ins><code>cfg_data.get()</code></ins></a></li>
<li><a href="Reference-manual_returned_cfg_data.html#cfg_dataget_unquoted"><ins><code>cfg_data.get_unquoted()</code></ins></a></li>
<li><a href="Reference-manual_returned_compiler.html#compilerget_argument_syntax"><ins><code>compiler.get_argument_syntax()</code></ins></a></li>
<li><a href="Reference-manual_returned_compiler.html#compilerget_define"><ins><code>compiler.get_define()</code></ins></a></li>
<li><a href="Reference-manual_returned_compiler.html#compilerget_id"><ins><code>compiler.get_id()</code></ins></a></li>
<li><a href="Reference-manual_returned_compiler.html#compilerget_linker_id"><ins><code>compiler.get_linker_id()</code></ins></a></li>
<li><a href="Reference-manual_returned_compiler.html#compilerversion"><ins><code>compiler.version()</code></ins></a></li>
<li><a href="Reference-manual_returned_custom_idx.html#custom_idxfull_path"><ins><code>custom_idx.full_path()</code></ins></a></li>
<li><a href="Reference-manual_returned_custom_tgt.html#custom_tgtfull_path"><ins><code>custom_tgt.full_path()</code></ins></a></li>
<li><a href="Reference-manual_returned_dep.html#depget_configtool_variable"><ins><code>dep.get_configtool_variable()</code></ins></a></li>
<li><a href="Reference-manual_returned_dep.html#depget_pkgconfig_variable"><ins><code>dep.get_pkgconfig_variable()</code></ins></a></li>
<li><a href="Reference-manual_returned_dep.html#depget_variable"><ins><code>dep.get_variable()</code></ins></a></li>
<li><a href="Reference-manual_returned_dep.html#depinclude_type"><ins><code>dep.include_type()</code></ins></a></li>
<li><a href="Reference-manual_returned_dep.html#depname"><ins><code>dep.name()</code></ins></a></li>
<li><a href="Reference-manual_returned_dep.html#deptype_name"><ins><code>dep.type_name()</code></ins></a></li>
<li><a href="Reference-manual_returned_dep.html#depversion"><ins><code>dep.version()</code></ins></a></li>
<li><a href="Reference-manual_returned_external_program.html#external_programfull_path"><ins><code>external_program.full_path()</code></ins></a></li>
<li><a href="Reference-manual_returned_external_program.html#external_programpath"><ins><code>external_program.path()</code></ins></a></li>
<li><a href="Reference-manual_returned_external_program.html#external_programversion"><ins><code>external_program.version()</code></ins></a></li>
<li><a href="Reference-manual_returned_file.html#filefull_path"><ins><code>file.full_path()</code></ins></a></li>
<li><a href="Reference-manual_elementary_int.html#intto_string"><ins><code>int.to_string()</code></ins></a></li>
<li><a href="Reference-manual_builtin_meson.html#mesonbackend"><ins><code>meson.backend()</code></ins></a></li>
<li><a href="Reference-manual_builtin_meson.html#mesonbuild_options"><ins><code>meson.build_options()</code></ins></a></li>
<li><a href="Reference-manual_builtin_meson.html#mesonbuild_root"><ins><code>meson.build_root()</code></ins></a></li>
<li><a href="Reference-manual_builtin_meson.html#mesoncurrent_build_dir"><ins><code>meson.current_build_dir()</code></ins></a></li>
<li><a href="Reference-manual_builtin_meson.html#mesoncurrent_source_dir"><ins><code>meson.current_source_dir()</code></ins></a></li>
<li><a href="Reference-manual_builtin_meson.html#mesonglobal_build_root"><ins><code>meson.global_build_root()</code></ins></a></li>
<li><a href="Reference-manual_builtin_meson.html#mesonglobal_source_root"><ins><code>meson.global_source_root()</code></ins></a></li>
<li><a href="Reference-manual_builtin_meson.html#mesonproject_build_root"><ins><code>meson.project_build_root()</code></ins></a></li>
<li><a href="Reference-manual_builtin_meson.html#mesonproject_name"><ins><code>meson.project_name()</code></ins></a></li>
<li><a href="Reference-manual_builtin_meson.html#mesonproject_source_root"><ins><code>meson.project_source_root()</code></ins></a></li>
<li><a href="Reference-manual_builtin_meson.html#mesonproject_version"><ins><code>meson.project_version()</code></ins></a></li>
<li><a href="Reference-manual_builtin_meson.html#mesonsource_root"><ins><code>meson.source_root()</code></ins></a></li>
<li><a href="Reference-manual_builtin_meson.html#mesonversion"><ins><code>meson.version()</code></ins></a></li>
<li><a href="Reference-manual_returned_runresult.html#runresultstderr"><ins><code>runresult.stderr()</code></ins></a></li>
<li><a href="Reference-manual_returned_runresult.html#runresultstdout"><ins><code>runresult.stdout()</code></ins></a></li>
<li><a href="Reference-manual_elementary_str.html#strformat"><ins><code>str.format()</code></ins></a></li>
<li><a href="Reference-manual_elementary_str.html#strjoin"><ins><code>str.join()</code></ins></a></li>
<li><a href="Reference-manual_elementary_str.html#strreplace"><ins><code>str.replace()</code></ins></a></li>
<li><a href="Reference-manual_elementary_str.html#strstrip"><ins><code>str.strip()</code></ins></a></li>
<li><a href="Reference-manual_elementary_str.html#strsubstring"><ins><code>str.substring()</code></ins></a></li>
<li><a href="Reference-manual_elementary_str.html#strto_lower"><ins><code>str.to_lower()</code></ins></a></li>
<li><a href="Reference-manual_elementary_str.html#strto_upper"><ins><code>str.to_upper()</code></ins></a></li>
<li><a href="Reference-manual_elementary_str.html#strunderscorify"><ins><code>str.underscorify()</code></ins></a></li>
</ul>
<h2 id="string-methods">String methods</h2>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strcontains">str.contains()</h3>
<p>Returns <code>true</code> if string contains the string specified as the argument.</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
</div>
</div>
</div>
<pre><code class="language-meson"># Returns `true` if string contains the string specified as the argument
<a href="Reference-manual_elementary_bool.html"><ins>bool</ins></a> contains(
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> <a href="Reference-manual_elementary_str.html#contains_fragment"><b>fragment</b></a>, # The string fragment to check
)</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example">Example</h4>
<pre><code class="language-meson">target = 'x86_FreeBSD'
is_fbsd = target.to_lower().contains('freebsd')
# is_fbsd now has the boolean value 'true'
</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="arguments">Arguments</h4>
<p>The method <code>str.contains()</code> accepts the following positional arguments:</p>
<!-- Hotdoc / markdown inserts <p> around the table elements. Override the margin to make them invisible -->
<style>
.nomargin p:last-child { margin-bottom: 0px !important; }
</style>
<table>
<thead>
<tr>
<th style="white-space: nowrap; text-align: center;">Name</th>
<th style="white-space: nowrap; text-align: center;">Type</th>
<th style="width: 56%;">Description</th>
<th style="white-space: nowrap; text-align: center; width: 0px;">Tags</th>
</tr>
</thead>
<tbody class="nomargin">
<tr id="contains_fragment">
<td style="white-space: nowrap; text-align: center; padding: 6px;"><code class="language-meson">fragment</code></td>
<td style="white-space: revert; text-align: center; padding: 6px; word-wrap: break-word;"><a href="Reference-manual_elementary_str.html"><ins><code>str</code></ins></a></td>
<!-- This suboptimal formatting is required to ensure hotdoc correctly generates the HTML -->
<td style="width: 56%; padding: 6px;">
<p>The string fragment to check</p>
</td>
<td style="white-space: nowrap; text-align: center; padding: 6px; width: 0px;">
<div style="margin: 0px; text-align: center;">
</div>
</td>
</tr>
</tbody>
</table>
<p style="padding: 5px; margin: 0px;"></p> <!-- Extra space -->
<p style="padding: 7.5px; margin: 0px;"></p>
<hr>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strendswith">str.endswith()</h3>
<p>Returns true if string ends with the string specified as the argument.</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature1">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
</div>
</div>
</div>
<pre><code class="language-meson"># Returns true if string ends with the string specified as the argument
<a href="Reference-manual_elementary_bool.html"><ins>bool</ins></a> endswith(
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> <a href="Reference-manual_elementary_str.html#endswith_fragment"><b>fragment</b></a>, # The string fragment to check
)</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example1">Example</h4>
<pre><code class="language-meson">target = 'x86_FreeBSD'
is_bsd = target.to_lower().endswith('bsd') # boolean value 'true'
</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="arguments1">Arguments</h4>
<p>The method <code>str.endswith()</code> accepts the following positional arguments:</p>
<!-- Hotdoc / markdown inserts <p> around the table elements. Override the margin to make them invisible -->
<style>
.nomargin p:last-child { margin-bottom: 0px !important; }
</style>
<table>
<thead>
<tr>
<th style="white-space: nowrap; text-align: center;">Name</th>
<th style="white-space: nowrap; text-align: center;">Type</th>
<th style="width: 56%;">Description</th>
<th style="white-space: nowrap; text-align: center; width: 0px;">Tags</th>
</tr>
</thead>
<tbody class="nomargin">
<tr id="endswith_fragment">
<td style="white-space: nowrap; text-align: center; padding: 6px;"><code class="language-meson">fragment</code></td>
<td style="white-space: revert; text-align: center; padding: 6px; word-wrap: break-word;"><a href="Reference-manual_elementary_str.html"><ins><code>str</code></ins></a></td>
<!-- This suboptimal formatting is required to ensure hotdoc correctly generates the HTML -->
<td style="width: 56%; padding: 6px;">
<p>The string fragment to check</p>
</td>
<td style="white-space: nowrap; text-align: center; padding: 6px; width: 0px;">
<div style="margin: 0px; text-align: center;">
</div>
</td>
</tr>
</tbody>
</table>
<p style="padding: 5px; margin: 0px;"></p> <!-- Extra space -->
<p style="padding: 7.5px; margin: 0px;"></p>
<hr>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strformat">str.format()</h3>
<p>Strings can be built using the string formatting functionality.</p>
<p>See <a href="Syntax.html#string-formatting">the Meson syntax entry</a> for more
information.</p>
<p><em>Since 1.3.0</em> values other than strings, integers, bools, options,
dictionaries and lists thereof are deprecated. They were previously printing
the internal representation of the raw Python object.</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature2">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
</div>
</div>
</div>
<pre><code class="language-meson"># Strings can be built using the string formatting functionality
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> format(
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> <a href="Reference-manual_elementary_str.html#format_fmt"><b>fmt</b></a>, # The string to format
<a href="Reference-manual_elementary_int.html"><ins>int</ins></a> | <a href="Reference-manual_elementary_bool.html"><ins>bool</ins></a> | <a href="Reference-manual_elementary_str.html"><ins>str</ins></a> <b>value</b>..., # The values to replace the @number@ placeholders in the format string
)</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example2">Example</h4>
<pre><code class="language-meson">template = 'string: @0@, number: @1@, bool: @2@'
res = template.format('text', 1, true)
# res now has value 'string: text, number: 1, bool: true'
</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="arguments2">Arguments</h4>
<p><a href="Syntax.html#argument-flattening">Argument flattening</a> is <strong>NOT SUPPORTED</strong> by this function.</p>
<p>The method <code>str.format()</code> accepts the following positional arguments:</p>
<!-- Hotdoc / markdown inserts <p> around the table elements. Override the margin to make them invisible -->
<style>
.nomargin p:last-child { margin-bottom: 0px !important; }
</style>
<table>
<thead>
<tr>
<th style="white-space: nowrap; text-align: center;">Name</th>
<th style="white-space: nowrap; text-align: center;">Type</th>
<th style="width: 56%;">Description</th>
<th style="white-space: nowrap; text-align: center; width: 0px;">Tags</th>
</tr>
</thead>
<tbody class="nomargin">
<tr id="format_fmt">
<td style="white-space: nowrap; text-align: center; padding: 6px;"><code class="language-meson">fmt</code></td>
<td style="white-space: revert; text-align: center; padding: 6px; word-wrap: break-word;"><a href="Reference-manual_elementary_str.html"><ins><code>str</code></ins></a></td>
<!-- This suboptimal formatting is required to ensure hotdoc correctly generates the HTML -->
<td style="width: 56%; padding: 6px;">
<p>The string to format.</p>
<p>The formatting works by replacing placeholders of type <code>@number@</code> with
the corresponding varargs.</p>
</td>
<td style="white-space: nowrap; text-align: center; padding: 6px; width: 0px;">
<div style="margin: 0px; text-align: center;">
</div>
</td>
</tr>
</tbody>
</table>
<p style="padding: 5px; margin: 0px;"></p> <!-- Extra space -->
<p>Additionally, the
method accepts between <code>0</code> and <code>infinity</code> variadic
arguments (<code>value...</code>) of type <code><a href="Reference-manual_elementary_int.html"><ins><code>int</code></ins></a> | <a href="Reference-manual_elementary_bool.html"><ins><code>bool</code></ins></a> | <a href="Reference-manual_elementary_str.html"><ins><code>str</code></ins></a></code>.</p>
<p>The values to replace the @number@ placeholders in the format string.</p>
<div style="margin: 0px; text-align: center;">
</div>
<p style="padding: 5px; margin: 0px;"></p> <!-- Extra space -->
<p style="padding: 7.5px; margin: 0px;"></p>
<hr>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strjoin">str.join()</h3>
<p>The opposite of split,
for example <code>'.'.join(['a', 'b', 'c']</code> yields <code>'a.b.c'</code>.</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature3">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
</div>
</div>
</div>
<pre><code class="language-meson"># The opposite of split,
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> join(
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> <b>strings</b>..., # The strings to join with the current string
)</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example3">Example</h4>
<pre><code class="language-meson"># Similar to the Python str.join()
output = ' '.join(['foo', 'bar'])
# Output value is 'foo bar'
pathsep = ':'
path = pathsep.join(['/usr/bin', '/bin', '/usr/local/bin'])
# path now has the value '/usr/bin:/bin:/usr/local/bin'
</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="arguments3">Arguments</h4>
<p>The
method accepts between <code>0</code> and <code>infinity</code> variadic
arguments (<code>strings...</code>) of type <code><a href="Reference-manual_elementary_str.html"><ins><code>str</code></ins></a></code>.</p>
<p>The strings to join with the current string.</p>
<p>Before Meson <em>0.60.0</em> this function only accepts a single positional
argument of the type [[list[str]]].</p>
<div style="margin: 0px; text-align: center;">
<p style="margin: 0px;"><em style="color: #5affff;">(since 0.60.0)</em></p>
</div>
<p style="padding: 5px; margin: 0px;"></p> <!-- Extra space -->
<p style="padding: 7.5px; margin: 0px;"></p>
<hr>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strreplace">str.replace()</h3>
<p>Search all occurrences of <code>old</code> and replace it with <code>new</code></p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature4">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
<p style="margin: 0px;"><em style="color: #5affff;">(since 0.58.0)</em></p>
</div>
</div>
</div>
<pre><code class="language-meson"># Search all occurrences of `old` and replace it with `new`
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> replace(
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> <a href="Reference-manual_elementary_str.html#replace_old"><b>old</b></a>, # The substring to search
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> <a href="Reference-manual_elementary_str.html#replace_new"><b>new</b></a>, # The replacement string
)</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example4">Example</h4>
<pre><code class="language-meson"># Replaces all instances of one substring with another
s = 'semicolons;as;separators'
s = s.replace('as', 'are')
# 's' now has the value of 'semicolons;are;separators'
</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="arguments4">Arguments</h4>
<p>The method <code>str.replace()</code> accepts the following positional arguments:</p>
<!-- Hotdoc / markdown inserts <p> around the table elements. Override the margin to make them invisible -->
<style>
.nomargin p:last-child { margin-bottom: 0px !important; }
</style>
<table>
<thead>
<tr>
<th style="white-space: nowrap; text-align: center;">Name</th>
<th style="white-space: nowrap; text-align: center;">Type</th>
<th style="width: 56%;">Description</th>
<th style="white-space: nowrap; text-align: center; width: 0px;">Tags</th>
</tr>
</thead>
<tbody class="nomargin">
<tr id="replace_old">
<td style="white-space: nowrap; text-align: center; padding: 6px;"><code class="language-meson">old</code></td>
<td style="white-space: revert; text-align: center; padding: 6px; word-wrap: break-word;"><a href="Reference-manual_elementary_str.html"><ins><code>str</code></ins></a></td>
<!-- This suboptimal formatting is required to ensure hotdoc correctly generates the HTML -->
<td style="width: 56%; padding: 6px;">
<p>The substring to search</p>
</td>
<td style="white-space: nowrap; text-align: center; padding: 6px; width: 0px;">
<div style="margin: 0px; text-align: center;">
</div>
</td>
</tr>
<tr id="replace_new">
<td style="white-space: nowrap; text-align: center; padding: 6px;"><code class="language-meson">new</code></td>
<td style="white-space: revert; text-align: center; padding: 6px; word-wrap: break-word;"><a href="Reference-manual_elementary_str.html"><ins><code>str</code></ins></a></td>
<!-- This suboptimal formatting is required to ensure hotdoc correctly generates the HTML -->
<td style="width: 56%; padding: 6px;">
<p>The replacement string</p>
</td>
<td style="white-space: nowrap; text-align: center; padding: 6px; width: 0px;">
<div style="margin: 0px; text-align: center;">
</div>
</td>
</tr>
</tbody>
</table>
<p style="padding: 5px; margin: 0px;"></p> <!-- Extra space -->
<p style="padding: 7.5px; margin: 0px;"></p>
<hr>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strsplit">str.split()</h3>
<p>Splits the string at the specified character
(or whitespace if not set) and returns the parts in an
array.</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature5">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
</div>
</div>
</div>
<pre><code class="language-meson"># Splits the string at the specified character
<a href="Reference-manual_elementary_list.html"><ins>list</ins></a>[<a href="Reference-manual_elementary_str.html"><ins>str</ins></a>] split(
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> [<a href="Reference-manual_elementary_str.html#split_split_string"><b>split_string</b></a>], # Specifies the character / substring where to split the string
)</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example5">Example</h4>
<pre><code class="language-meson"># Similar to the Python str.split()
components = 'a b c d '.split()
# components now has the value ['a', 'b', 'c', 'd']
components = 'a b c d '.split(' ')
# components now has the value ['a', 'b', '', '', 'c', 'd', '']
</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="arguments5">Arguments</h4>
<p>The method <code>str.split()</code> accepts the following positional arguments:</p>
<!-- Hotdoc / markdown inserts <p> around the table elements. Override the margin to make them invisible -->
<style>
.nomargin p:last-child { margin-bottom: 0px !important; }
</style>
<table>
<thead>
<tr>
<th style="white-space: nowrap; text-align: center;">Name</th>
<th style="white-space: nowrap; text-align: center;">Type</th>
<th style="width: 56%;">Description</th>
<th style="white-space: nowrap; text-align: center; width: 0px;">Tags</th>
</tr>
</thead>
<tbody class="nomargin">
<tr id="split_split_string">
<td style="white-space: nowrap; text-align: center; padding: 6px;"><code class="language-meson">split_string</code></td>
<td style="white-space: revert; text-align: center; padding: 6px; word-wrap: break-word;"><a href="Reference-manual_elementary_str.html"><ins><code>str</code></ins></a></td>
<!-- This suboptimal formatting is required to ensure hotdoc correctly generates the HTML -->
<td style="width: 56%; padding: 6px;">
<p>Specifies the character / substring where to split the string.</p>
</td>
<td style="white-space: nowrap; text-align: center; padding: 6px; width: 0px;">
<div style="margin: 0px; text-align: center;">
<p style="margin: 0px;"><b>[optional]</b></p>
</div>
</td>
</tr>
</tbody>
</table>
<p style="padding: 5px; margin: 0px;"></p> <!-- Extra space -->
<p style="padding: 7.5px; margin: 0px;"></p>
<hr>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strsplitlines">str.splitlines()</h3>
<p>Splits the string into an array of lines.
Unlike .split('\n'), the empty string produced an empty array,
and if the string ends in a newline, splitlines() doesn't split
on that last newline.
'\n', '\r' and '\r\n' are all considered newlines.</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature6">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
<p style="margin: 0px;"><em style="color: #5affff;">(since 1.2.0)</em></p>
</div>
</div>
</div>
<pre><code class="language-meson"><a href="Reference-manual_elementary_list.html"><ins>list</ins></a>[<a href="Reference-manual_elementary_str.html"><ins>str</ins></a>] splitlines()</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example6">Example</h4>
<pre><code class="language-meson">output = 'hello\nworld\n'.splitlines()
# Output value is ['hello', 'world']
output = ''.splitlines()
# Output value is []
fs = import('fs')
paths = fs.read('my_paths.list').splitlines()
# paths is now the paths listed in 'my_paths.list', or an empty list
# if 'my_paths.list' is empty
</code></pre>
<p style="padding: 7.5px; margin: 0px;"></p>
<hr>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strstartswith">str.startswith()</h3>
<p>Returns true if string starts with the string specified as the argument.</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature7">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
</div>
</div>
</div>
<pre><code class="language-meson"># Returns true if string starts with the string specified as the argument
<a href="Reference-manual_elementary_bool.html"><ins>bool</ins></a> startswith(
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> <a href="Reference-manual_elementary_str.html#startswith_fragment"><b>fragment</b></a>, # The string fragment to check
)</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example7">Example</h4>
<pre><code class="language-meson">target = 'x86_FreeBSD'
is_x86 = target.startswith('x86') # boolean value 'true'
</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="arguments6">Arguments</h4>
<p>The method <code>str.startswith()</code> accepts the following positional arguments:</p>
<!-- Hotdoc / markdown inserts <p> around the table elements. Override the margin to make them invisible -->
<style>
.nomargin p:last-child { margin-bottom: 0px !important; }
</style>
<table>
<thead>
<tr>
<th style="white-space: nowrap; text-align: center;">Name</th>
<th style="white-space: nowrap; text-align: center;">Type</th>
<th style="width: 56%;">Description</th>
<th style="white-space: nowrap; text-align: center; width: 0px;">Tags</th>
</tr>
</thead>
<tbody class="nomargin">
<tr id="startswith_fragment">
<td style="white-space: nowrap; text-align: center; padding: 6px;"><code class="language-meson">fragment</code></td>
<td style="white-space: revert; text-align: center; padding: 6px; word-wrap: break-word;"><a href="Reference-manual_elementary_str.html"><ins><code>str</code></ins></a></td>
<!-- This suboptimal formatting is required to ensure hotdoc correctly generates the HTML -->
<td style="width: 56%; padding: 6px;">
<p>The string fragment to check</p>
</td>
<td style="white-space: nowrap; text-align: center; padding: 6px; width: 0px;">
<div style="margin: 0px; text-align: center;">
</div>
</td>
</tr>
</tbody>
</table>
<p style="padding: 5px; margin: 0px;"></p> <!-- Extra space -->
<p style="padding: 7.5px; margin: 0px;"></p>
<hr>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strstrip">str.strip()</h3>
<p>Removes leading/ending characters from the string.</p>
<p>By default the characters to remove are spaces and newlines.</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature8">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
</div>
</div>
</div>
<pre><code class="language-meson"># Removes leading/ending characters from the string
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> strip(
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> [<a href="Reference-manual_elementary_str.html#strip_strip_chars"><b>strip_chars</b></a>], # Instead of whitespace, strip all the characters in this string
)</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example8">Example</h4>
<pre><code class="language-meson"># Similar to the Python str.strip(). Removes leading/ending spaces and newlines
define = ' -Dsomedefine '
stripped_define = define.strip()
# 'stripped_define' now has the value '-Dsomedefine'
</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="arguments7">Arguments</h4>
<p>The method <code>str.strip()</code> accepts the following positional arguments:</p>
<!-- Hotdoc / markdown inserts <p> around the table elements. Override the margin to make them invisible -->
<style>
.nomargin p:last-child { margin-bottom: 0px !important; }
</style>
<table>
<thead>
<tr>
<th style="white-space: nowrap; text-align: center;">Name</th>
<th style="white-space: nowrap; text-align: center;">Type</th>
<th style="width: 56%;">Description</th>
<th style="white-space: nowrap; text-align: center; width: 0px;">Tags</th>
</tr>
</thead>
<tbody class="nomargin">
<tr id="strip_strip_chars">
<td style="white-space: nowrap; text-align: center; padding: 6px;"><code class="language-meson">strip_chars</code></td>
<td style="white-space: revert; text-align: center; padding: 6px; word-wrap: break-word;"><a href="Reference-manual_elementary_str.html"><ins><code>str</code></ins></a></td>
<!-- This suboptimal formatting is required to ensure hotdoc correctly generates the HTML -->
<td style="width: 56%; padding: 6px;">
<p>Instead of whitespace, strip all the characters in this string.</p>
</td>
<td style="white-space: nowrap; text-align: center; padding: 6px; width: 0px;">
<div style="margin: 0px; text-align: center;">
<p style="margin: 0px;"><em style="color: #5affff;">(since 0.43.0)</em></p>
<p style="margin: 0px;"><b>[optional]</b></p>
</div>
</td>
</tr>
</tbody>
</table>
<p style="padding: 5px; margin: 0px;"></p> <!-- Extra space -->
<p style="padding: 7.5px; margin: 0px;"></p>
<hr>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strsubstring">str.substring()</h3>
<p>Returns a substring specified from <code>start</code> to <code>end</code>.
Both <code>start</code> and <code>end</code> arguments are optional, so, for example, <code>'foobar'.substring()</code> will return <code>'foobar'</code>.</p>
<p>The method accepts negative values where negative <code>start</code> is relative to the end of
string <code>len(string) - start</code> as well as negative <code>end</code>.</p>
<p>If <code>start</code> or <code>end</code> are out of bounds, the position of the closest character will be used.
If <code>start</code> is bigger than <code>end</code>, the result will be an empty substring.</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature9">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
<p style="margin: 0px;"><em style="color: #5affff;">(since 0.56.0)</em></p>
</div>
</div>
</div>
<pre><code class="language-meson"># Returns a substring specified from `start` to `end`
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> substring(
<a href="Reference-manual_elementary_int.html"><ins>int</ins></a> [<a href="Reference-manual_elementary_str.html#substring_start"><b>start</b></a>], # The start position
<a href="Reference-manual_elementary_int.html"><ins>int</ins></a> [<a href="Reference-manual_elementary_str.html#substring_end"><b>end</b></a>], # The end position
)</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example9">Example</h4>
<pre><code class="language-meson"># Similar to the Python str[start:end] syntax
target = 'x86_FreeBSD'
platform = target.substring(0, 3) # prefix string value 'x86'
system = target.substring(4) # suffix string value 'FreeBSD'
</code></pre>
<p>Example with negative values:</p>
<pre><code class="language-meson">string = 'foobar'
string.substring(-5, -3) # => 'oo'
string.substring(1, -1) # => 'ooba'
</code></pre>
<p>Example with out of bound values:</p>
<pre><code class="language-meson">string = 'foobar'
string.substring(64) # => ''
string.substring(0, 64) # => 'foobar'
string.substring(64, 0) # => ''
</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="arguments8">Arguments</h4>
<p>The method <code>str.substring()</code> accepts the following positional arguments:</p>
<!-- Hotdoc / markdown inserts <p> around the table elements. Override the margin to make them invisible -->
<style>
.nomargin p:last-child { margin-bottom: 0px !important; }
</style>
<table>
<thead>
<tr>
<th style="white-space: nowrap; text-align: center;">Name</th>
<th style="white-space: nowrap; text-align: center;">Type</th>
<th style="width: 56%;">Description</th>
<th style="white-space: nowrap; text-align: center; width: 0px;">Tags</th>
</tr>
</thead>
<tbody class="nomargin">
<tr id="substring_start">
<td style="white-space: nowrap; text-align: center; padding: 6px;"><code class="language-meson">start</code></td>
<td style="white-space: revert; text-align: center; padding: 6px; word-wrap: break-word;"><a href="Reference-manual_elementary_int.html"><ins><code>int</code></ins></a></td>
<!-- This suboptimal formatting is required to ensure hotdoc correctly generates the HTML -->
<td style="width: 56%; padding: 6px;">
<p>The start position</p>
</td>
<td style="white-space: nowrap; text-align: center; padding: 6px; width: 0px;">
<div style="margin: 0px; text-align: center;">
<p style="margin: 0px;"><b>[optional]</b></p>
</div>
</td>
</tr>
<tr id="substring_end">
<td style="white-space: nowrap; text-align: center; padding: 6px;"><code class="language-meson">end</code></td>
<td style="white-space: revert; text-align: center; padding: 6px; word-wrap: break-word;"><a href="Reference-manual_elementary_int.html"><ins><code>int</code></ins></a></td>
<!-- This suboptimal formatting is required to ensure hotdoc correctly generates the HTML -->
<td style="width: 56%; padding: 6px;">
<p>The end position</p>
</td>
<td style="white-space: nowrap; text-align: center; padding: 6px; width: 0px;">
<div style="margin: 0px; text-align: center;">
<p style="margin: 0px;"><b>[optional]</b></p>
</div>
</td>
</tr>
</tbody>
</table>
<p style="padding: 5px; margin: 0px;"></p> <!-- Extra space -->
<p style="padding: 7.5px; margin: 0px;"></p>
<hr>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strto_int">str.to_int()</h3>
<p>Converts the string to an int and throws an error if it can't be</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature10">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
</div>
</div>
</div>
<pre><code class="language-meson"><a href="Reference-manual_elementary_int.html"><ins>int</ins></a> to_int()</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example10">Example</h4>
<pre><code class="language-meson">version = '1'
# Converts the string to an int and throws an error if it can't be
ver_int = version.to_int()
</code></pre>
<p style="padding: 7.5px; margin: 0px;"></p>
<hr>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strto_lower">str.to_lower()</h3>
<p>Converts all characters to lower case</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature11">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
</div>
</div>
</div>
<pre><code class="language-meson"><a href="Reference-manual_elementary_str.html"><ins>str</ins></a> to_lower()</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example11">Example</h4>
<pre><code class="language-meson">target = 'x86_FreeBSD'
lower = target.to_lower() # t now has the value 'x86_freebsd'
</code></pre>
<p style="padding: 7.5px; margin: 0px;"></p>
<hr>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strto_upper">str.to_upper()</h3>
<p>Converts all characters to upper case</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature12">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
</div>
</div>
</div>
<pre><code class="language-meson"><a href="Reference-manual_elementary_str.html"><ins>str</ins></a> to_upper()</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example12">Example</h4>
<pre><code class="language-meson">target = 'x86_FreeBSD'
upper = target.to_upper() # t now has the value 'X86_FREEBSD'
</code></pre>
<p style="padding: 7.5px; margin: 0px;"></p>
<hr>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strunderscorify">str.underscorify()</h3>
<p>Creates a string where every non-alphabetical non-number character is replaced with <code>_</code>.</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature13">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
</div>
</div>
</div>
<pre><code class="language-meson"><a href="Reference-manual_elementary_str.html"><ins>str</ins></a> underscorify()</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example13">Example</h4>
<pre><code class="language-meson">name = 'Meson Docs.txt#Reference-manual'
# Replaces all characters other than `a-zA-Z0-9` with `_` (underscore)
# Useful for substituting into #defines, filenames, etc.
underscored = name.underscorify()
# underscored now has the value 'Meson_Docs_txt_Reference_manual'
</code></pre>
<p style="padding: 7.5px; margin: 0px;"></p>
<hr>
<p style="padding: 7.5px; margin: 0px;"></p>
<h3 id="strversion_compare">str.version_compare()</h3>
<p>Does semantic version comparison.</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit of space because we remove the top margin below -->
<div style="display: flex;">
<h4 style="margin-top: 0px;" id="signature14">Signature</h4>
<div style="flex-grow: 1;"></div>
<div>
<div style="margin: 0px; text-align: center;">
</div>
</div>
</div>
<pre><code class="language-meson"># Does semantic version comparison
<a href="Reference-manual_elementary_bool.html"><ins>bool</ins></a> version_compare(
<a href="Reference-manual_elementary_str.html"><ins>str</ins></a> <a href="Reference-manual_elementary_str.html#version_compare_compare_string"><b>compare_string</b></a>, # The string to compare to
)</code></pre>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="example14">Example</h4>
<pre><code class="language-meson">version = '1.2.3'
# Compare version numbers semantically
is_new = version.version_compare('>=2.0')
# is_new now has the boolean value false
# Supports the following operators: '>', '<', '>=', '<=', '!=', '==', '='
</code></pre>
<p>Meson version comparison conventions include:</p>
<pre><code class="language-meson">'3.6'.version_compare('>=3.6.0') == false
</code></pre>
<p>It is best to be unambiguous and specify the full revision level to compare.</p>
<p style="padding: 5px; margin: 0px;"></p> <!-- A bit more space -->
<h4 id="arguments9">Arguments</h4>
<p>The method <code>str.version_compare()</code> accepts the following positional arguments:</p>
<!-- Hotdoc / markdown inserts <p> around the table elements. Override the margin to make them invisible -->
<style>
.nomargin p:last-child { margin-bottom: 0px !important; }
</style>
<table>
<thead>
<tr>
<th style="white-space: nowrap; text-align: center;">Name</th>
<th style="white-space: nowrap; text-align: center;">Type</th>
<th style="width: 56%;">Description</th>
<th style="white-space: nowrap; text-align: center; width: 0px;">Tags</th>
</tr>
</thead>
<tbody class="nomargin">
<tr id="version_compare_compare_string">
<td style="white-space: nowrap; text-align: center; padding: 6px;"><code class="language-meson">compare_string</code></td>
<td style="white-space: revert; text-align: center; padding: 6px; word-wrap: break-word;"><a href="Reference-manual_elementary_str.html"><ins><code>str</code></ins></a></td>
<!-- This suboptimal formatting is required to ensure hotdoc correctly generates the HTML -->
<td style="width: 56%; padding: 6px;">