EVOLUTION-MANAGER
Edit File: col_substring.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: Substring(s) of 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 col_substring {crayon}"><tr><td>col_substring {crayon}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Substring(s) of an ANSI colored string</h2> <h3>Description</h3> <p>This is the color-aware counterpart of <code><a href="../../base/html/substring.html">base::substring()</a></code>. It works exactly like the original, but keeps the colors in the substrings. The ANSI escape sequences are ignored when calculating the positions within the string. </p> <h3>Usage</h3> <pre> col_substring(text, first, last = 1000000L) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>text</code></td> <td> <p>Character vector, potentially ANSI styled, or a vector to coarced to character. It is recycled to the longest of <code>first</code> and <code>last</code>.</p> </td></tr> <tr valign="top"><td><code>first</code></td> <td> <p>Starting index or indices, recycled to match the length of <code>x</code>.</p> </td></tr> <tr valign="top"><td><code>last</code></td> <td> <p>Ending index or indices, recycled to match the length of <code>x</code>.</p> </td></tr> </table> <h3>Value</h3> <p>Character vector of the same length as <code>x</code>, containing the requested substrings. ANSI styles are retained. </p> <h3>See Also</h3> <p>Other ANSI string operations: <code><a href="col_align.html">col_align</a></code>, <code><a href="col_nchar.html">col_nchar</a></code>, <code><a href="col_strsplit.html">col_strsplit</a></code>, <code><a href="col_substr.html">col_substr</a></code> </p> <h3>Examples</h3> <pre> str <- paste( red("red"), "default", green("green") ) cat(str, "\n") cat(col_substring(str, 1, 5), "\n") cat(col_substring(str, 1, 15), "\n") cat(col_substring(str, 3, 7), "\n") substring(strip_style(str), 1, 5) substring(strip_style(str), 1, 15) substring(strip_style(str), 3, 7) str2 <- "another " %+% red("multi-", sep = "", underline("style")) %+% " text" cat(str2, "\n") cat(col_substring(str2, c(3,5), c(7, 18)), sep = "\n") substring(strip_style(str2), c(3,5), c(7, 18)) </pre> <hr /><div style="text-align: center;">[Package <em>crayon</em> version 1.3.4 <a href="00Index.html">Index</a>]</div> </body></html>