summaryrefslogtreecommitdiff
path: root/clojure.string-api.html
blob: 5bae6c34e923caf87dbf573f9ae1b15c48ed574f (plain)
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
<html>
  <head>
    <title>clojure.string - Clojure v1.2 API documentation</title>
    <link href="static/favicon.png" rel="icon" />
    <link href="static/favicon.png" rel="shortcut icon" />
    <link media="all" type="text/css" href="static/clojure.css" rel="stylesheet" />
    <link media="all" type="text/css" href="static/wiki.css" rel="stylesheet" />
    <link media="all" type="text/css" href="static/internal.css" rel="stylesheet" />
    <style>.menuWrapper{height: 36px;}</style>
    <!--[if lte IE 6]>
    <link rel="stylesheet" href="http://www.wikispaces.com/_/2009051601/s/internal_ie.css" type="text/css" />
    <![endif]-->
  </head>
<!--
This document was auto-generated from the source by the clojure autodoc system.
To report errors or ask questions about the overall documentation structure, formatting,
etc., contact Tom Faulhaber (google mail name: tomfaulhaber).
For errors in the documentation of a particular namespace, contact the author of that
namespace.
-->
  <body>
    <div id="AllContentContainer">
      <div id="Header">
	<a id="Logo" href="index.html"><img alt="Clojure" height="100" width="100" src="static/clojure-icon.gif" /></a>
	<h1><a title="page header title" id="page-header" href="index.html">Clojure Core API Reference</a></h1>
      </div>
      <div id="leftcolumn"><div style="text-align: center;"></div>
<div class="menu">
  <div class="WikiCustomNav WikiElement wiki">
    <span class="toc-header"><span id="project-name">Clojure</span> <span id="version">v1.2</span> API</span><br />
    <ul>
      <li><a class="wiki_link" href="index.html">Overview</a></li>
      <li><a class="wiki_link" href="api-index.html">API Index</a></li>
    </ul>
    <span class="toc-header">Namespaces</span>
    <ul id="left-sidebar-list">
      <li><a href="clojure.core-api.html" class="wiki_link">clojure.core</a></li><li><a href="clojure.inspector-api.html" class="wiki_link">clojure.inspector</a></li><li><a href="clojure.java.browse-api.html" class="wiki_link">clojure.java.browse</a></li><li><a href="clojure.java.io-api.html" class="wiki_link">clojure.java.io</a></li><li><a href="clojure.java.javadoc-api.html" class="wiki_link">clojure.java.javadoc</a></li><li><a href="clojure.java.shell-api.html" class="wiki_link">clojure.java.shell</a></li><li><a href="clojure.main-api.html" class="wiki_link">clojure.main</a></li><li><a href="clojure.pprint-api.html" class="wiki_link">clojure.pprint</a></li><li><a href="clojure.repl-api.html" class="wiki_link">clojure.repl</a></li><li><a href="clojure.set-api.html" class="wiki_link">clojure.set</a></li><li><a href="clojure.stacktrace-api.html" class="wiki_link">clojure.stacktrace</a></li><li><a href="clojure.string-api.html" class="wiki_link">clojure.string</a></li><li><a href="clojure.template-api.html" class="wiki_link">clojure.template</a></li><li><a href="clojure.test-api.html" class="wiki_link">clojure.test</a></li><li><a href="clojure.walk-api.html" class="wiki_link">clojure.walk</a></li><li><a href="clojure.xml-api.html" class="wiki_link">clojure.xml</a></li><li><a href="clojure.zip-api.html" class="wiki_link">clojure.zip</a></li>
    </ul>
    <div class="BranchTOC">
      <span class="toc-header">Other Versions</span>
      <ul id="left-sidebar-branch-list">
        <li><a href="branch-master/index.html" class="wiki_link">v1.3 (in development)</a></li><li><a href="branch-1.1.x/index.html" class="wiki_link">v1.1 (stable)</a></li>
      </ul>
    </div>
    <a href="http://clojure.org" class="wiki_link">Clojure Home</a>
  </div>
</div>
</div>
      <div id="rightcolumn">
	<div id="Content">
	  <div class="contentBox"><div class="innerContentBox">
              <div id="content_view" class="wiki wikiPage">
                <div id="right-sidebar"><div id="toc">
  <h1 class="nopad">Table of Contents</h1>
  <div style="margin-left: 1em;" class="toc-section">
    <a href="#toc0">Overview</a>
    <div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/blank?">blank?</a>
    </div><div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/capitalize">capitalize</a>
    </div><div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/escape">escape</a>
    </div><div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/join">join</a>
    </div><div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/lower-case">lower-case</a>
    </div><div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/replace">replace</a>
    </div><div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/replace-first">replace-first</a>
    </div><div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/reverse">reverse</a>
    </div><div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/split">split</a>
    </div><div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/split-lines">split-lines</a>
    </div><div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/trim">trim</a>
    </div><div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/trim-newline">trim-newline</a>
    </div><div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/triml">triml</a>
    </div><div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/trimr">trimr</a>
    </div><div style="margin-left: 1em;" class="toc-entry">
      <a href="#clojure.string/upper-case">upper-case</a>
    </div>
    <br />
  </div>
</div>
</div>
                <div id="content-tag"><h1 id="overview">API for <span id="namespace-name">clojure.string</span>
  - <span id="header-project">Clojure</span> <span id="header-version">v1.2</span> (<span id="header-status">stable</span>)
  </h1>
<span id="author-line">by <span id="author-name">Stuart Sierra, Stuart Halloway, David Liebke</span><br /></span>
<br />Full namespace name: <span id="long-name">clojure.string</span>
<p></p>
<h2>Overview</h2>
<pre id="namespace-docstr">Clojure String utilities

It is poor form to (:use clojure.string). Instead, use require
with :as to specify a prefix, e.g.

(ns your.namespace.here
  (:require '[clojure.string :as str]))

Design notes for clojure.string:

1. Strings are objects (as opposed to sequences). As such, the
   string being manipulated is the first argument to a function;
   passing nil will result in a NullPointerException unless
   documented otherwise. If you want sequence-y behavior instead,
   use a sequence.

2. Functions are generally not lazy, and call straight to host
   methods where those are available and efficient.

3. Functions take advantage of String implementation details to
   write high-performing loop/recurs instead of using higher-order
   functions. (This is not idiomatic in general-purpose application
   code.)

4. When a function is documented to accept a string argument, it
   will take any implementation of the correct *interface* on the
   host platform. In Java, this is CharSequence, which is more
   general than String. In ordinary usage you will almost always
   pass concrete strings. If you are doing something unusual,
   e.g. passing a mutable implementation of CharSequence, then
   thead-safety is your responsibility.</pre>


<br />
<h2>Public Variables and Functions</h2>
<div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/blank?">blank?</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (blank? s)
</pre>
  <pre id="var-docstr">True if s is nil, empty, or contains only whitespace.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L225" id="var-source">Source</a>
</div><div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/capitalize">capitalize</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (capitalize s)
</pre>
  <pre id="var-docstr">Converts first character of the string to upper-case, all other
characters to lower-case.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L146" id="var-source">Source</a>
</div><div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/escape">escape</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (escape s cmap)
</pre>
  <pre id="var-docstr">Return a new string, using cmap to escape each character ch
from s as follows:

If (cmap ch) is nil, append ch to the new string.
If (cmap ch) is non-nil, append (str (cmap ch)) instead.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L238" id="var-source">Source</a>
</div><div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/join">join</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (join coll)
       (join separator [x &amp; more])
</pre>
  <pre id="var-docstr">Returns a string of all elements in coll, separated by
an optional separator.  Like Perl's join.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L130" id="var-source">Source</a>
</div><div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/lower-case">lower-case</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (lower-case s)
</pre>
  <pre id="var-docstr">Converts string to all lower-case.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L163" id="var-source">Source</a>
</div><div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/replace">replace</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (replace s match replacement)
</pre>
  <pre id="var-docstr">Replaces all instance of match with replacement in s.

match/replacement can be:

string / string
char / char
pattern / (string or function of match).

See also replace-first.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L63" id="var-source">Source</a>
</div><div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/replace-first">replace-first</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (replace-first s match replacement)
</pre>
  <pre id="var-docstr">Replaces the first instance of match with replacement in s.

match/replacement can be:

char / char
string / string
pattern / (string or function of match).

See also replace-all.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L103" id="var-source">Source</a>
</div><div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/reverse">reverse</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (reverse s)
</pre>
  <pre id="var-docstr">Returns s with its characters reversed.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L46" id="var-source">Source</a>
</div><div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/split">split</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (split s re)
       (split s re limit)
</pre>
  <pre id="var-docstr">Splits string on a regular expression.  Optional argument limit is
the maximum number of splits. Not lazy. Returns vector of the splits.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L169" id="var-source">Source</a>
</div><div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/split-lines">split-lines</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (split-lines s)
</pre>
  <pre id="var-docstr">Splits s on \n or \r\n.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L178" id="var-source">Source</a>
</div><div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/trim">trim</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (trim s)
</pre>
  <pre id="var-docstr">Removes whitespace from both ends of string.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L184" id="var-source">Source</a>
</div><div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/trim-newline">trim-newline</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (trim-newline s)
</pre>
  <pre id="var-docstr">Removes all trailing newline \n or return \r characters from
string.  Similar to Perl's chomp.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L212" id="var-source">Source</a>
</div><div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/triml">triml</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (triml s)
</pre>
  <pre id="var-docstr">Removes whitespace from the left side of string.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L190" id="var-source">Source</a>
</div><div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/trimr">trimr</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (trimr s)
</pre>
  <pre id="var-docstr">Removes whitespace from the right side of string.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L201" id="var-source">Source</a>
</div><div id="var-entry">
  <br />
  <hr />
  <h2 id="clojure.string/upper-case">upper-case</h2>
  <span id="var-type">function</span><br />
  <pre id="var-usage">Usage: (upper-case s)
</pre>
  <pre id="var-docstr">Converts string to all upper-case.</pre>
  <span class="var-added"><span id="content">Added in Clojure version 1.2</span><br /></span>
  
  <a href="https://github.com/clojure/clojure/blob/fde4f64bb5eb5c87b618b37e3d69ac37f1531524/src/clj/clojure/string.clj#L157" id="var-source">Source</a>
</div>


</div>
              </div>
            </div>
          </div>
	</div>
	<div id="foot">
	  <div style="text-align: center;" id="copyright">Copyright 2007-2010 by Rich Hickey</div>
	</div>
      </div>
      <div id="DesignedBy">Logo &amp; site design by <a title="Visit Tom Hickey's website." href="http://www.tomhickey.com">Tom Hickey</a>.<br />
      Clojure auto-documentation system by Tom Faulhaber.</div>
    </div>
    <!-- /AllContentContainer -->
  </body>

</html>