EVOLUTION-MANAGER
Edit File: ansi_strsplit.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Split an ANSI colored string</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for ansi_strsplit {cli}"><tr><td>ansi_strsplit {cli}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Split an ANSI colored string</h2> <h3>Description</h3> <p>This is the color-aware counterpart of <code><a href="../../base/html/strsplit.html">base::strsplit()</a></code>. It works almost exactly like the original, but keeps the colors in the substrings. </p> <h3>Usage</h3> <pre> ansi_strsplit(x, split, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>Character vector, potentially ANSI styled, or a vector to coerced to character.</p> </td></tr> <tr valign="top"><td><code>split</code></td> <td> <p>Character vector of length 1 (or object which can be coerced to such) containing regular expression(s) (unless <code>fixed = TRUE</code>) to use for splitting. If empty matches occur, in particular if <code>split</code> has zero characters, <code>x</code> is split into single characters.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Extra arguments are passed to <code>base::strsplit()</code>.</p> </td></tr> </table> <h3>Value</h3> <p>A list of the same length as <code>x</code>, the <code>i</code>-th element of which contains the vector of splits of <code>x[i]</code>. ANSI styles are retained. </p> <h3>See Also</h3> <p>Other ANSI string operations: <code><a href="ansi_align.html">ansi_align</a>()</code>, <code><a href="ansi_columns.html">ansi_columns</a>()</code>, <code><a href="ansi_nchar.html">ansi_nchar</a>()</code>, <code><a href="ansi_strtrim.html">ansi_strtrim</a>()</code>, <code><a href="ansi_strwrap.html">ansi_strwrap</a>()</code>, <code><a href="ansi_substring.html">ansi_substring</a>()</code>, <code><a href="ansi_substr.html">ansi_substr</a>()</code>, <code><a href="ansi_toupper.html">ansi_toupper</a>()</code>, <code><a href="ansi_trimws.html">ansi_trimws</a>()</code> </p> <h3>Examples</h3> <pre> str <- paste0( col_red("I am red---"), col_green("and I am green-"), style_underline("I underlined") ) cat(str, "\n") # split at dashes, keep color cat(ansi_strsplit(str, "[-]+")[[1]], sep = "\n") strsplit(ansi_strip(str), "[-]+") # split to characters, keep color cat(ansi_strsplit(str, "")[[1]], "\n", sep = " ") strsplit(ansi_strip(str), "") </pre> <hr /><div style="text-align: center;">[Package <em>cli</em> version 3.4.1 <a href="00Index.html">Index</a>]</div> </body></html>