1Stdlib.StringLabels(3)           OCaml library          Stdlib.StringLabels(3)
2
3
4

NAME

6       Stdlib.StringLabels - no description
7

Module

9       Module   Stdlib.StringLabels
10

Documentation

12       Module StringLabels
13        : (module Stdlib__stringLabels)
14
15
16
17
18
19
20
21
22       val length : string -> int
23
24       Return the length (number of characters) of the given string.
25
26
27
28       val get : string -> int -> char
29
30
31       String.get  s n returns the character at index n in string s .  You can
32       also write s.[n] instead of String.get s n .
33
34
35       Raises Invalid_argument if n not a valid index in s .
36
37
38
39       val set : bytes -> int -> char -> unit
40
41       Deprecated.  This is a deprecated alias of BytesLabels.set .
42
43
44
45       String.set s n c modifies byte sequence s in place, replacing the  byte
46       at  index  n  with  c  .   You  can  also  write  s.[n] <- c instead of
47       String.set s n c .
48
49
50       Raises Invalid_argument if n is not a valid index in s .
51
52
53
54       val create : int -> bytes
55
56       Deprecated.  This is a deprecated alias of BytesLabels.create .
57
58
59
60       String.create n returns a fresh byte sequence of length n  .   The  se‐
61       quence is uninitialized and contains arbitrary bytes.
62
63
64       Raises Invalid_argument if n < 0 or n > Sys.max_string_length .
65
66
67
68       val make : int -> char -> string
69
70
71       String.make  n  c  returns a fresh string of length n , filled with the
72       character c .
73
74
75       Raises Invalid_argument if n < 0 or n > Sys.max_string_length .
76
77
78
79       val init : int -> f:(int -> char) -> string
80
81
82       init n f returns a string of length n , with character i initialized to
83       the result of f i .
84
85
86       Since 4.02.0
87
88
89       Raises Invalid_argument if n < 0 or n > Sys.max_string_length .
90
91
92
93       val copy : string -> string
94
95       Return a copy of the given string.
96
97
98
99       val sub : string -> pos:int -> len:int -> string
100
101
102       String.sub  s start len returns a fresh string of length len , contain‐
103       ing the substring of s that starts at position start and has length len
104       .
105
106
107       Raises  Invalid_argument if start and len do not designate a valid sub‐
108       string of s .
109
110
111
112       val fill : bytes -> pos:int -> len:int -> char -> unit
113
114       Deprecated.  This is a deprecated alias of BytesLabels.fill .
115
116
117
118       String.fill s start len c modifies byte sequence s in place,  replacing
119       len bytes by c , starting at start .
120
121
122       Raises  Invalid_argument if start and len do not designate a valid sub‐
123       string of s .
124
125
126
127       val blit : src:string -> src_pos:int ->  dst:bytes  ->  dst_pos:int  ->
128       len:int -> unit
129
130
131       String.blit  src srcoff dst dstoff len copies len bytes from the string
132       src , starting at index srcoff , to byte sequence  dst  ,  starting  at
133       character number dstoff .
134
135
136       Raises  Invalid_argument  if  srcoff  and  len do not designate a valid
137       range of src , or if dstoff and len do not designate a valid  range  of
138       dst .
139
140
141
142       val concat : sep:string -> string list -> string
143
144
145       String.concat  sep  sl  concatenates the list of strings sl , inserting
146       the separator string sep between each.
147
148
149
150       val iter : f:(char -> unit) -> string -> unit
151
152
153       String.iter f s applies function f in turn to all the characters of s .
154       It  is  equivalent to f s.[0]; f s.[1]; ...; f s.[String.length s - 1];
155       () .
156
157
158
159       val iteri : f:(int -> char -> unit) -> string -> unit
160
161       Same as String.iter , but the function is applied to the index  of  the
162       element  as  first argument (counting from 0), and the character itself
163       as second argument.
164
165
166       Since 4.00.0
167
168
169
170       val map : f:(char -> char) -> string -> string
171
172
173       String.map f s applies function f in turn to all the  characters  of  s
174       and stores the results in a new string that is returned.
175
176
177       Since 4.00.0
178
179
180
181       val mapi : f:(int -> char -> char) -> string -> string
182
183
184       String.mapi  f s calls f with each character of s and its index (in in‐
185       creasing index order) and stores the results in a new  string  that  is
186       returned.
187
188
189       Since 4.02.0
190
191
192
193       val trim : string -> string
194
195       Return a copy of the argument, without leading and trailing whitespace.
196       The characters regarded as whitespace are: ' ' , '\012' , '\n' , '\r' ,
197       and '\t' .  If there is no leading nor trailing whitespace character in
198       the argument, return the original string itself, not a copy.
199
200
201       Since 4.00.0
202
203
204
205       val escaped : string -> string
206
207       Return a copy of the argument, with special characters  represented  by
208       escape sequences, following the lexical conventions of OCaml.  If there
209       is no special character in the argument, return the original string it‐
210       self, not a copy. Its inverse function is Scanf.unescaped.
211
212
213
214       val index : string -> char -> int
215
216
217       String.index s c returns the index of the first occurrence of character
218       c in string s .
219
220
221       Raises Not_found if c does not occur in s .
222
223
224
225       val index_opt : string -> char -> int option
226
227
228       String.index_opt s c returns the index of the first occurrence of char‐
229       acter c in string s , or None if c does not occur in s .
230
231
232       Since 4.05
233
234
235
236       val rindex : string -> char -> int
237
238
239       String.rindex s c returns the index of the last occurrence of character
240       c in string s .
241
242
243       Raises Not_found if c does not occur in s .
244
245
246
247       val rindex_opt : string -> char -> int option
248
249
250       String.rindex_opt s c returns the index of the last occurrence of char‐
251       acter c in string s , or None if c does not occur in s .
252
253
254       Since 4.05
255
256
257
258       val index_from : string -> int -> char -> int
259
260
261       String.index_from  s  i  c returns the index of the first occurrence of
262       character c in string s after position i .  String.index s c is equiva‐
263       lent to String.index_from s 0 c .
264
265
266       Raises Invalid_argument if i is not a valid position in s .
267
268
269       Raises Not_found if c does not occur in s after position i .
270
271
272
273       val index_from_opt : string -> int -> char -> int option
274
275
276       String.index_from_opt  s  i c returns the index of the first occurrence
277       of character c in string s after position i or None if c does not occur
278       in s after position i .
279
280
281       String.index_opt s c is equivalent to String.index_from_opt s 0 c .
282
283
284       Since 4.05
285
286
287       Raises Invalid_argument if i is not a valid position in s .
288
289
290
291       val rindex_from : string -> int -> char -> int
292
293
294       String.rindex_from  s  i  c returns the index of the last occurrence of
295       character c in string s before position i+1 .   String.rindex  s  c  is
296       equivalent to String.rindex_from s (String.length s - 1) c .
297
298
299       Raises Invalid_argument if i+1 is not a valid position in s .
300
301
302       Raises Not_found if c does not occur in s before position i+1 .
303
304
305
306       val rindex_from_opt : string -> int -> char -> int option
307
308
309       String.rindex_from_opt  s  i c returns the index of the last occurrence
310       of character c in string s before position i+1 or None if  c  does  not
311       occur in s before position i+1 .
312
313
314       String.rindex_opt   s  c  is  equivalent  to  String.rindex_from_opt  s
315       (String.length s - 1) c .
316
317
318       Since 4.05
319
320
321       Raises Invalid_argument if i+1 is not a valid position in s .
322
323
324
325       val contains : string -> char -> bool
326
327
328       String.contains s c tests if character c appears in the string s .
329
330
331
332       val contains_from : string -> int -> char -> bool
333
334
335       String.contains_from s start c tests if character c appears in s  after
336       position  start  .   String.contains  s  c is equivalent to String.con‐
337       tains_from s 0 c .
338
339
340       Raises Invalid_argument if start is not a valid position in s .
341
342
343
344       val rcontains_from : string -> int -> char -> bool
345
346
347       String.rcontains_from s stop c tests if character c appears in s before
348       position stop+1 .
349
350
351       Raises  Invalid_argument  if stop < 0 or stop+1 is not a valid position
352       in s .
353
354
355
356       val uppercase : string -> string
357
358       Deprecated.  Functions operating on Latin-1 character  set  are  depre‐
359       cated.
360
361
362       Return a copy of the argument, with all lowercase letters translated to
363       uppercase, including accented letters of the ISO Latin-1 (8859-1) char‐
364       acter set.
365
366
367
368       val lowercase : string -> string
369
370       Deprecated.   Functions  operating  on Latin-1 character set are depre‐
371       cated.
372
373
374       Return a copy of the argument, with all uppercase letters translated to
375       lowercase, including accented letters of the ISO Latin-1 (8859-1) char‐
376       acter set.
377
378
379
380       val capitalize : string -> string
381
382       Deprecated.  Functions operating on Latin-1 character  set  are  depre‐
383       cated.
384
385
386       Return  a  copy of the argument, with the first character set to upper‐
387       case, using the ISO Latin-1 (8859-1) character set..
388
389
390
391       val uncapitalize : string -> string
392
393       Deprecated.  Functions operating on Latin-1 character  set  are  depre‐
394       cated.
395
396
397       Return  a  copy of the argument, with the first character set to lower‐
398       case, using the ISO Latin-1 (8859-1) character set..
399
400
401
402       val uppercase_ascii : string -> string
403
404       Return a copy of the argument, with all lowercase letters translated to
405       uppercase, using the US-ASCII character set.
406
407
408       Since 4.05.0
409
410
411
412       val lowercase_ascii : string -> string
413
414       Return a copy of the argument, with all uppercase letters translated to
415       lowercase, using the US-ASCII character set.
416
417
418       Since 4.05.0
419
420
421
422       val capitalize_ascii : string -> string
423
424       Return a copy of the argument, with the first character set  to  upper‐
425       case, using the US-ASCII character set.
426
427
428       Since 4.05.0
429
430
431
432       val uncapitalize_ascii : string -> string
433
434       Return  a  copy of the argument, with the first character set to lower‐
435       case, using the US-ASCII character set.
436
437
438       Since 4.05.0
439
440
441       type t = string
442
443
444       An alias for the type of strings.
445
446
447
448       val compare : t -> t -> int
449
450       The comparison function for strings, with  the  same  specification  as
451       compare  .   Along  with  the type t , this function compare allows the
452       module String to be passed as argument to  the  functors  Set.Make  and
453       Map.Make .
454
455
456
457       val equal : t -> t -> bool
458
459       The equal function for strings.
460
461
462       Since 4.05.0
463
464
465
466       val split_on_char : sep:char -> string -> string list
467
468
469       String.split_on_char  sep  s  returns  the list of all (possibly empty)
470       substrings of s that are delimited by the sep character.
471
472       The function's output is specified by the following invariants:
473
474
475       -The list is not empty.
476
477       -Concatenating its elements using sep as a separator returns  a  string
478       equal to the input ( String.concat (String.make 1 sep)
479             (String.split_on_char sep s) = s ).
480
481       -No string in the result contains the sep character.
482
483
484
485       Since 4.05.0
486
487
488
489
490   Iterators
491       val to_seq : t -> char Seq.t
492
493       Iterate  on the string, in increasing index order. Modifications of the
494       string during iteration will be reflected in the iterator.
495
496
497       Since 4.07
498
499
500
501       val to_seqi : t -> (int * char) Seq.t
502
503       Iterate on the string, in  increasing  order,  yielding  indices  along
504       chars
505
506
507       Since 4.07
508
509
510
511       val of_seq : char Seq.t -> t
512
513       Create a string from the generator
514
515
516       Since 4.07
517
518
519
520
521
522OCamldoc                          2021-01-26            Stdlib.StringLabels(3)
Impressum