mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
2 lines
No EOL
9.7 KiB
HTML
2 lines
No EOL
9.7 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Split (containers.CCStringLabels.Split)</title><link rel="stylesheet" href="../../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc %%VERSION%%"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> – <a href="../../index.html">containers</a> » <a href="../index.html">CCStringLabels</a> » Split</nav><h1>Module <code>CCStringLabels.Split</code></h1><nav class="toc"><ul><li><a href="#copying-functions">Copying functions</a></li></ul></nav></header><dl><dt class="spec type" id="type-drop_if_empty"><a href="#type-drop_if_empty" class="anchor"></a><code><span class="keyword">type</span> drop_if_empty</code><code> = </code><code>{</code><table class="record"><tr id="type-drop_if_empty.first" class="anchored"><td class="def field"><a href="#type-drop_if_empty.first" class="anchor"></a><code>first : bool;</code></td></tr><tr id="type-drop_if_empty.last" class="anchored"><td class="def field"><a href="#type-drop_if_empty.last" class="anchor"></a><code>last : bool;</code></td></tr></table><code>}</code></dt><dd><p>Specification of what to do with empty blocks, as in <code>split ~by:"-" "-a-b-"</code>.</p><ul><li><code>{first=false; last=false}</code> will return <code>""; "a"; "b"; ""</code></li><li><code>{first=true; last=false}</code> will return <code>"a"; "b" ""</code></li><li><code>{first=false; last=true}</code> will return <code>""; "a"; "b"</code></li><li><code>{first=true; last=true}</code> will return <code>"a"; "b"</code></li></ul><p>The default value of all remaining functions is <code>Drop_none</code>.</p><dl><dt>since</dt><dd>1.5</dd></dl></dd></dl><dl><dt class="spec value" id="val-no_drop"><a href="#val-no_drop" class="anchor"></a><code><span class="keyword">val</span> no_drop : <a href="index.html#type-drop_if_empty">drop_if_empty</a></code></dt><dd><p>Do not drop any group, even empty and on borders.</p><dl><dt>since</dt><dd>1.5</dd></dl></dd></dl><dl><dt class="spec value" id="val-list_"><a href="#val-list_" class="anchor"></a><code><span class="keyword">val</span> list_ : <span>?⁠drop:<a href="index.html#type-drop_if_empty">drop_if_empty</a></span> <span>-></span> <span>by:string</span> <span>-></span> string <span>-></span> <span><span>(string * int * int)</span> list</span></code></dt><dd><p>Split the given string along the given separator <code>by</code>. Should only be used with very small separators, otherwise use <span class="xref-unresolved" title="unresolved reference to "Containers_string.KMP""><code>Containers_string</code>.KMP</span>.</p><dl><dt>returns</dt><dd><p>a list of slices <code>(s,index,length)</code> that are separated by <code>by</code>. <span class="xref-unresolved" title="unresolved reference to "String.sub""><code>String</code>.sub</span> can then be used to actually extract a string from the slice.</p></dd></dl><dl><dt>raises Failure</dt><dd><p>if <code>by = ""</code>.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-gen"><a href="#val-gen" class="anchor"></a><code><span class="keyword">val</span> gen : <span>?⁠drop:<a href="index.html#type-drop_if_empty">drop_if_empty</a></span> <span>-></span> <span>by:string</span> <span>-></span> string <span>-></span> <span><span>(string * int * int)</span> <a href="../index.html#type-gen">gen</a></span></code></dt><dt class="spec value" id="val-iter"><a href="#val-iter" class="anchor"></a><code><span class="keyword">val</span> iter : <span>?⁠drop:<a href="index.html#type-drop_if_empty">drop_if_empty</a></span> <span>-></span> <span>by:string</span> <span>-></span> string <span>-></span> <span><span>(string * int * int)</span> <a href="../index.html#type-sequence">sequence</a></span></code></dt><dd><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-std_seq"><a href="#val-std_seq" class="anchor"></a><code><span class="keyword">val</span> std_seq : <span>?⁠drop:<a href="index.html#type-drop_if_empty">drop_if_empty</a></span> <span>-></span> <span>by:string</span> <span>-></span> string <span>-></span> <span><span>(string * int * int)</span> Seq.t</span></code></dt><dd><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-seq"><a href="#val-seq" class="anchor"></a><code><span class="keyword">val</span> seq : <span>?⁠drop:<a href="index.html#type-drop_if_empty">drop_if_empty</a></span> <span>-></span> <span>by:string</span> <span>-></span> string <span>-></span> <span><span>(string * int * int)</span> <a href="../index.html#type-sequence">sequence</a></span></code></dt><dt class="spec value" id="val-klist"><a href="#val-klist" class="anchor"></a><code><span class="keyword">val</span> klist : <span>?⁠drop:<a href="index.html#type-drop_if_empty">drop_if_empty</a></span> <span>-></span> <span>by:string</span> <span>-></span> string <span>-></span> <span><span>(string * int * int)</span> <a href="../index.html#type-klist">klist</a></span></code></dt></dl><section><header><h5 id="copying-functions"><a href="#copying-functions" class="anchor"></a>Copying functions</h5><p>Those split functions actually copy the substrings, which can be more convenient but less efficient in general.</p></header><dl><dt class="spec value" id="val-list_cpy"><a href="#val-list_cpy" class="anchor"></a><code><span class="keyword">val</span> list_cpy : <span>?⁠drop:<a href="index.html#type-drop_if_empty">drop_if_empty</a></span> <span>-></span> <span>by:string</span> <span>-></span> string <span>-></span> <span>string list</span></code></dt><dt class="spec value" id="val-gen_cpy"><a href="#val-gen_cpy" class="anchor"></a><code><span class="keyword">val</span> gen_cpy : <span>?⁠drop:<a href="index.html#type-drop_if_empty">drop_if_empty</a></span> <span>-></span> <span>by:string</span> <span>-></span> string <span>-></span> <span>string <a href="../index.html#type-gen">gen</a></span></code></dt><dt class="spec value" id="val-iter_cpy"><a href="#val-iter_cpy" class="anchor"></a><code><span class="keyword">val</span> iter_cpy : <span>?⁠drop:<a href="index.html#type-drop_if_empty">drop_if_empty</a></span> <span>-></span> <span>by:string</span> <span>-></span> string <span>-></span> <span>string <a href="../index.html#type-sequence">sequence</a></span></code></dt><dd><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-std_seq_cpy"><a href="#val-std_seq_cpy" class="anchor"></a><code><span class="keyword">val</span> std_seq_cpy : <span>?⁠drop:<a href="index.html#type-drop_if_empty">drop_if_empty</a></span> <span>-></span> <span>by:string</span> <span>-></span> string <span>-></span> <span>string Seq.t</span></code></dt><dd><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-seq_cpy"><a href="#val-seq_cpy" class="anchor"></a><code><span class="keyword">val</span> seq_cpy : <span>?⁠drop:<a href="index.html#type-drop_if_empty">drop_if_empty</a></span> <span>-></span> <span>by:string</span> <span>-></span> string <span>-></span> <span>string <a href="../index.html#type-sequence">sequence</a></span></code></dt><dt class="spec value" id="val-klist_cpy"><a href="#val-klist_cpy" class="anchor"></a><code><span class="keyword">val</span> klist_cpy : <span>?⁠drop:<a href="index.html#type-drop_if_empty">drop_if_empty</a></span> <span>-></span> <span>by:string</span> <span>-></span> string <span>-></span> <span>string <a href="../index.html#type-klist">klist</a></span></code></dt><dt class="spec value" id="val-left"><a href="#val-left" class="anchor"></a><code><span class="keyword">val</span> left : <span>by:string</span> <span>-></span> string <span>-></span> <span><span>(string * string)</span> option</span></code></dt><dd><p>Split on the first occurrence of <code>by</code> from the leftmost part of the string.</p><dl><dt>since</dt><dd>0.12</dd></dl></dd></dl><dl><dt class="spec value" id="val-left_exn"><a href="#val-left_exn" class="anchor"></a><code><span class="keyword">val</span> left_exn : <span>by:string</span> <span>-></span> string <span>-></span> string * string</code></dt><dd><p>Split on the first occurrence of <code>by</code> from the leftmost part of the string.</p><dl><dt>raises Not_found</dt><dd><p>if <code>by</code> is not part of the string.</p></dd></dl><dl><dt>since</dt><dd>0.16</dd></dl></dd></dl><dl><dt class="spec value" id="val-right"><a href="#val-right" class="anchor"></a><code><span class="keyword">val</span> right : <span>by:string</span> <span>-></span> string <span>-></span> <span><span>(string * string)</span> option</span></code></dt><dd><p>Split on the first occurrence of <code>by</code> from the rightmost part of the string.</p><dl><dt>since</dt><dd>0.12</dd></dl></dd></dl><dl><dt class="spec value" id="val-right_exn"><a href="#val-right_exn" class="anchor"></a><code><span class="keyword">val</span> right_exn : <span>by:string</span> <span>-></span> string <span>-></span> string * string</code></dt><dd><p>Split on the first occurrence of <code>by</code> from the rightmost part of the string.</p><dl><dt>raises Not_found</dt><dd><p>if <code>by</code> is not part of the string.</p></dd></dl><dl><dt>since</dt><dd>0.16</dd></dl></dd></dl></section></div></body></html> |