ocaml-containers/3.13/containers/CCString/Split/index.html
2023-12-05 15:53:19 -05:00

18 lines
No EOL
12 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Split (containers.CCString.Split)</title><link rel="stylesheet" href="../../../odoc.support/odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 2.2.2"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../odoc.support/highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> <a href="../../index.html">containers</a> &#x00BB; <a href="../index.html">CCString</a> &#x00BB; Split</nav><header class="odoc-preamble"><h1>Module <code><span>CCString.Split</span></code></h1></header><nav class="odoc-toc"><ul><li><a href="#copying-functions">Copying functions</a></li></ul></nav><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-drop_if_empty"><a href="#type-drop_if_empty" class="anchor"></a><code><span><span class="keyword">type</span> drop_if_empty</span><span> = </span><span>{</span></code><ol><li id="type-drop_if_empty.first" class="def record field anchored"><a href="#type-drop_if_empty.first" class="anchor"></a><code><span>first : bool;</span></code></li><li id="type-drop_if_empty.last" class="def record field anchored"><a href="#type-drop_if_empty.last" class="anchor"></a><code><span>last : bool;</span></code></li></ol><code><span>}</span></code></div><div class="spec-doc"><p>Specification of what to do with empty blocks, as in <code>split ~by:&quot;-&quot; &quot;-a-b-&quot;</code>.</p><ul><li><code>{first=false; last=false}</code> will return <code>&quot;&quot;; &quot;a&quot;; &quot;b&quot;; &quot;&quot;</code></li><li><code>{first=true; last=false}</code> will return <code>&quot;a&quot;; &quot;b&quot; &quot;&quot;</code></li><li><code>{first=false; last=true}</code> will return <code>&quot;&quot;; &quot;a&quot;; &quot;b&quot;</code></li><li><code>{first=true; last=true}</code> will return <code>&quot;a&quot;; &quot;b&quot;</code></li></ul><p>The default value of all remaining functions is <code>Drop_none</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 1.5</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-no_drop"><a href="#val-no_drop" class="anchor"></a><code><span><span class="keyword">val</span> no_drop : <a href="#type-drop_if_empty">drop_if_empty</a></span></code></div><div class="spec-doc"><p><code>no_drop</code> does not drop any group, even empty and on borders.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 1.5</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-list_"><a href="#val-list_" class="anchor"></a><code><span><span class="keyword">val</span> list_ :
<span>?drop:<a href="#type-drop_if_empty">drop_if_empty</a> <span class="arrow">&#45;&gt;</span></span>
<span>by:string <span class="arrow">&#45;&gt;</span></span>
<span>string <span class="arrow">&#45;&gt;</span></span>
<span><span>(string * int * int)</span> list</span></span></code></div><div class="spec-doc"><p><code>list_ ~drop ~by s</code> splits the given string <code>s</code> along the given separator <code>by</code>. Should only be used with very small separators.</p><ul class="at-tags"><li class="returns"><span class="at-tag">returns</span> <p>a <code>list</code> of slices <code>(s,index,length)</code> that are separated by <code>by</code>. <code>String</code>.sub can then be used to actually extract a string from the slice.</p></li></ul><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Failure</span> <p>if <code>by = &quot;&quot;</code>.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-gen"><a href="#val-gen" class="anchor"></a><code><span><span class="keyword">val</span> gen :
<span>?drop:<a href="#type-drop_if_empty">drop_if_empty</a> <span class="arrow">&#45;&gt;</span></span>
<span>by:string <span class="arrow">&#45;&gt;</span></span>
<span>string <span class="arrow">&#45;&gt;</span></span>
<span><span>(string * int * int)</span> <a href="../index.html#type-gen">gen</a></span></span></code></div><div class="spec-doc"><p><code>gen ~drop ~by s</code> splits the given string <code>s</code> along the given separator <code>by</code>. Returns a <code>gen</code> of slices.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-iter"><a href="#val-iter" class="anchor"></a><code><span><span class="keyword">val</span> iter :
<span>?drop:<a href="#type-drop_if_empty">drop_if_empty</a> <span class="arrow">&#45;&gt;</span></span>
<span>by:string <span class="arrow">&#45;&gt;</span></span>
<span>string <span class="arrow">&#45;&gt;</span></span>
<span><span>(string * int * int)</span> <a href="../index.html#type-iter">iter</a></span></span></code></div><div class="spec-doc"><p><code>iter ~drop ~by s</code> splits the given string <code>s</code> along the given separator <code>by</code>. Returns an <code>iter</code> of slices.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 2.8</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-seq"><a href="#val-seq" class="anchor"></a><code><span><span class="keyword">val</span> seq :
<span>?drop:<a href="#type-drop_if_empty">drop_if_empty</a> <span class="arrow">&#45;&gt;</span></span>
<span>by:string <span class="arrow">&#45;&gt;</span></span>
<span>string <span class="arrow">&#45;&gt;</span></span>
<span><span>(string * int * int)</span> <span class="xref-unresolved">Stdlib</span>.Seq.t</span></span></code></div><div class="spec-doc"><p><code>seq ~drop ~by s</code> splits the given string <code>s</code> along the given separator <code>by</code>. Returns a <code>Seq.t</code> of slices. Renamed from <code>std_seq</code> since 3.0.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.0</li></ul></div></div><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><div class="odoc-spec"><div class="spec value anchored" id="val-list_cpy"><a href="#val-list_cpy" class="anchor"></a><code><span><span class="keyword">val</span> list_cpy : <span>?drop:<a href="#type-drop_if_empty">drop_if_empty</a> <span class="arrow">&#45;&gt;</span></span> <span>by:string <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> <span>string list</span></span></code></div><div class="spec-doc"><p><code>list_cpy ~drop ~by s</code> splits the given string <code>s</code> along the given separator <code>by</code>. Returns a <code>list</code> of strings.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-gen_cpy"><a href="#val-gen_cpy" class="anchor"></a><code><span><span class="keyword">val</span> gen_cpy : <span>?drop:<a href="#type-drop_if_empty">drop_if_empty</a> <span class="arrow">&#45;&gt;</span></span> <span>by:string <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> <span>string <a href="../index.html#type-gen">gen</a></span></span></code></div><div class="spec-doc"><p><code>gen_cpy ~drop ~by s</code> splits the given string <code>s</code> along the given separator <code>by</code>. Returns a <code>gen</code> of strings.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-iter_cpy"><a href="#val-iter_cpy" class="anchor"></a><code><span><span class="keyword">val</span> iter_cpy : <span>?drop:<a href="#type-drop_if_empty">drop_if_empty</a> <span class="arrow">&#45;&gt;</span></span> <span>by:string <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> <span>string <a href="../index.html#type-iter">iter</a></span></span></code></div><div class="spec-doc"><p><code>iter_cpy ~drop ~by s</code> splits the given string <code>s</code> along the given separator <code>by</code>. Returns an <code>iter</code> of strings.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 2.8</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-seq_cpy"><a href="#val-seq_cpy" class="anchor"></a><code><span><span class="keyword">val</span> seq_cpy : <span>?drop:<a href="#type-drop_if_empty">drop_if_empty</a> <span class="arrow">&#45;&gt;</span></span> <span>by:string <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> <span>string <span class="xref-unresolved">Stdlib</span>.Seq.t</span></span></code></div><div class="spec-doc"><p><code>seq_cpy ~drop ~by s</code> splits the given string <code>s</code> along the given separator <code>by</code>. Returns a <code>Seq.t</code> of strings. Renamed from <code>std_seq_cpy</code> since 3.0.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-left"><a href="#val-left" class="anchor"></a><code><span><span class="keyword">val</span> left : <span>by:string <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> <span><span>(string * string)</span> option</span></span></code></div><div class="spec-doc"><p><code>left ~by s</code> splits on the first occurrence of <code>by</code> from the leftmost part of the string <code>s</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.12</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-left_exn"><a href="#val-left_exn" class="anchor"></a><code><span><span class="keyword">val</span> left_exn : <span>by:string <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> string * string</span></code></div><div class="spec-doc"><p><code>left_exn ~by s</code> splits on the first occurrence of <code>by</code> from the leftmost part of the string <code>s</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Not_found</span> <p>if <code>by</code> is not part of the string <code>s</code>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.16</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-right"><a href="#val-right" class="anchor"></a><code><span><span class="keyword">val</span> right : <span>by:string <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> <span><span>(string * string)</span> option</span></span></code></div><div class="spec-doc"><p><code>right ~by s</code> splits on the first occurrence of <code>by</code> from the rightmost part of the string <code>s</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.12</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-right_exn"><a href="#val-right_exn" class="anchor"></a><code><span><span class="keyword">val</span> right_exn : <span>by:string <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> string * string</span></code></div><div class="spec-doc"><p><code>right_exn ~by s</code> splits on the first occurrence of <code>by</code> from the rightmost part of the string <code>s</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Not_found</span> <p>if <code>by</code> is not part of the string <code>s</code>.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.16</li></ul></div></div></div></body></html>