1String(3)                        OCaml library                       String(3)
2
3
4

NAME

6       String - String operations.
7

Module

9       Module   String
10

Documentation

12       Module String
13        : sig end
14
15
16       String  operations.   Given  a string s of length l , we call character
17       number in s the index of a character in s .  Indexes start at 0  ,  and
18       we will call a character number valid in s if it falls within the range
19       [0...l-1] . A position is the point between two characters  or  at  the
20       beginning  or  end  of the string.  We call a position valid in s if it
21       falls within the range [0...l]  .  Note  that  character  number  n  is
22       between positions n and n+1 .
23
24       Two parameters start and len are said to designate a valid substring of
25       s if len >= 0 and start and start+len are valid positions in s .
26
27
28
29
30
31
32
33       val length : string -> int
34
35       Return the length (number of characters) of the given string.
36
37
38
39
40       val get : string -> int -> char
41
42
43       String.get s n returns character number n in string s .  You  can  also
44       write s.[n] instead of String.get s n .
45
46       Raise Invalid_argument if n not a valid character number in s .
47
48
49
50
51       val set : string -> int -> char -> unit
52
53
54       String.set  s  n  c modifies string s in place, replacing the character
55       number n by c .  You can also write s.[n] <- c instead of String.set  s
56       n c .
57
58       Raise Invalid_argument if n is not a valid character number in s .
59
60
61
62
63       val create : int -> string
64
65
66       String.create  n  returns a fresh string of length n .  The string ini‐
67       tially contains arbitrary characters.
68
69       Raise Invalid_argument if n < 0 or n > Sys.max_string_length .
70
71
72
73
74       val make : int -> char -> string
75
76
77       String.make n c returns a fresh string of length n ,  filled  with  the
78       character c .
79
80       Raise Invalid_argument if n < 0 or n > Sys.max_string_length .
81
82
83
84
85       val copy : string -> string
86
87       Return a copy of the given string.
88
89
90
91
92       val sub : string -> int -> int -> string
93
94
95       String.sub  s start len returns a fresh string of length len , contain‐
96       ing the substring of s that starts at position start and has length len
97       .
98
99       Raise  Invalid_argument  if start and len do not designate a valid sub‐
100       string of s .
101
102
103
104
105       val fill : string -> int -> int -> char -> unit
106
107
108       String.fill s start len c modifies string s  in  place,  replacing  len
109       characters by c , starting at start .
110
111       Raise  Invalid_argument  if start and len do not designate a valid sub‐
112       string of s .
113
114
115
116
117       val blit : string -> int -> string -> int -> int -> unit
118
119
120       String.blit src srcoff dst dstoff len copies len characters from string
121       src , starting at character number srcoff , to string dst , starting at
122       character number dstoff . It works correctly even if src  and  dst  are
123       the same string, and the source and destination intervals overlap.
124
125       Raise  Invalid_argument if srcoff and len do not designate a valid sub‐
126       string of src , or if dstoff and len do not designate a valid substring
127       of dst .
128
129
130
131
132       val concat : string -> string list -> string
133
134
135       String.concat  sep  sl  concatenates the list of strings sl , inserting
136       the separator string sep between each.
137
138
139
140
141       val iter : (char -> unit) -> string -> unit
142
143
144       String.iter f s applies function f in turn to all the characters of s .
145       It  is  equivalent to f s.[0]; f s.[1]; ...; f s.[String.length s - 1];
146       () .
147
148
149
150
151       val escaped : string -> string
152
153       Return a copy of the argument, with special characters  represented  by
154       escape  sequences, following the lexical conventions of Objective Caml.
155       If there is no special character in the argument, return  the  original
156       string itself, not a copy.
157
158
159
160
161       val index : string -> char -> int
162
163
164       String.index  s  c returns the character number of the first occurrence
165       of character c in string s .
166
167       Raise Not_found if c does not occur in s .
168
169
170
171
172       val rindex : string -> char -> int
173
174
175       String.rindex s c returns the character number of the  last  occurrence
176       of character c in string s .
177
178       Raise Not_found if c does not occur in s .
179
180
181
182
183       val index_from : string -> int -> char -> int
184
185
186       String.index_from  s  i  c  returns  the  character number of the first
187       occurrence of character c in string s after position i .   String.index
188       s c is equivalent to String.index_from s 0 c .
189
190       Raise  Invalid_argument  if  i  is  not  a valid position in s .  Raise
191       Not_found if c does not occur in s after position i .
192
193
194
195
196       val rindex_from : string -> int -> char -> int
197
198
199       String.rindex_from s i c returns  the  character  number  of  the  last
200       occurrence   of   character  c  in  string  s  before  position  i+1  .
201       String.rindex s c is equivalent to String.rindex_from s  (String.length
202       s - 1) c .
203
204       Raise  Invalid_argument  if  i+1  is not a valid position in s .  Raise
205       Not_found if c does not occur in s before position i+1 .
206
207
208
209
210       val contains : string -> char -> bool
211
212
213       String.contains s c tests if character c appears in the string s .
214
215
216
217
218       val contains_from : string -> int -> char -> bool
219
220
221       String.contains_from s start c tests if character c appears in s  after
222       position  start  .   String.contains  s  c is equivalent to String.con‐
223       tains_from s 0 c .
224
225       Raise Invalid_argument if start is not a valid position in s .
226
227
228
229
230       val rcontains_from : string -> int -> char -> bool
231
232
233       String.rcontains_from s stop c tests if character c appears in s before
234       position stop+1 .
235
236       Raise Invalid_argument if stop < 0 or stop+1 is not a valid position in
237       s .
238
239
240
241
242       val uppercase : string -> string
243
244       Return a copy of the argument, with all lowercase letters translated to
245       uppercase, including accented letters of the ISO Latin-1 (8859-1) char‐
246       acter set.
247
248
249
250
251       val lowercase : string -> string
252
253       Return a copy of the argument, with all uppercase letters translated to
254       lowercase, including accented letters of the ISO Latin-1 (8859-1) char‐
255       acter set.
256
257
258
259
260       val capitalize : string -> string
261
262       Return a copy of the argument, with the first character set  to  upper‐
263       case.
264
265
266
267
268       val uncapitalize : string -> string
269
270       Return  a  copy of the argument, with the first character set to lower‐
271       case.
272
273
274
275       type t = string
276
277
278       An alias for the type of strings.
279
280
281
282
283       val compare : t -> t -> int
284
285       The comparison function for strings, with  the  same  specification  as
286       Pervasives.compare  .   Along  with  the type t , this function compare
287       allows the module String to be  passed  as  argument  to  the  functors
288       Set.Make and Map.Make .
289
290
291
292
293
294
295OCamldoc                          2017-03-22                         String(3)
Impressum