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

NAME

6       StringLabels - String operations.
7

Module

9       Module   StringLabels
10

Documentation

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