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