EVOLUTION-MANAGER
Edit File: grepRaw.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: Pattern Matching for Raw Vectors</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 grepRaw {base}"><tr><td>grepRaw {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Pattern Matching for Raw Vectors</h2> <h3>Description</h3> <p><code>grepRaw</code> searches for substring <code>pattern</code> matches within a raw vector <code>x</code>. </p> <h3>Usage</h3> <pre> grepRaw(pattern, x, offset = 1L, ignore.case = FALSE, value = FALSE, fixed = FALSE, all = FALSE, invert = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>pattern</code></td> <td> <p>raw vector containing a <a href="regex.html">regular expression</a> (or fixed pattern for <code>fixed = TRUE</code>) to be matched in the given raw vector. Coerced by <code><a href="rawConversion.html">charToRaw</a></code> to a character string if possible.</p> </td></tr> <tr valign="top"><td><code>x</code></td> <td> <p>a raw vector where matches are sought, or an object which can be coerced by <code>charToRaw</code> to a raw vector. <a href="LongVectors.html">Long vectors</a> are not supported.</p> </td></tr> <tr valign="top"><td><code>ignore.case</code></td> <td> <p>if <code>FALSE</code>, the pattern matching is <em>case sensitive</em> and if <code>TRUE</code>, case is ignored during matching.</p> </td></tr> <tr valign="top"><td><code>offset</code></td> <td> <p>An integer specifying the offset from which the search should start. Must be positive. The beginning of line is defined to be at that offset so <code>"^"</code> will match there.</p> </td></tr> <tr valign="top"><td><code>value</code></td> <td> <p>logical. Determines the return value: see ‘Value’.</p> </td></tr> <tr valign="top"><td><code>fixed</code></td> <td> <p>logical. If <code>TRUE</code>, <code>pattern</code> is a pattern to be matched as is.</p> </td></tr> <tr valign="top"><td><code>all</code></td> <td> <p>logical. If <code>TRUE</code> all matches are returned, otherwise just the first one.</p> </td></tr> <tr valign="top"><td><code>invert</code></td> <td> <p>logical. If <code>TRUE</code> return indices or values for elements that do <em>not</em> match. Ignored (with a warning) unless <code>value = TRUE</code>.</p> </td></tr> </table> <h3>Details</h3> <p>Unlike <code><a href="grep.html">grep</a></code>, seeks matching patterns within the raw vector <code>x</code> . This has implications especially in the <code>all = TRUE</code> case, e.g., patterns matching empty strings are inherently infinite and thus may lead to unexpected results. </p> <p>The argument <code>invert</code> is interpreted as asking to return the complement of the match, which is only meaningful for <code>value = TRUE</code>. Argument <code>offset</code> determines the start of the search, not of the complement. Note that <code>invert = TRUE</code> with <code>all = TRUE</code> will split <code>x</code> into pieces delimited by the pattern including leading and trailing empty strings (consequently the use of regular expressions with <code>"^"</code> or <code>"$"</code> in that case may lead to less intuitive results). </p> <p>Some combinations of arguments such as <code>fixed = TRUE</code> with <code>value = TRUE</code> are supported but are less meaningful. </p> <h3>Value</h3> <p><code>grepRaw(value = FALSE)</code> returns an integer vector of the offsets at which matches have occurred. If <code>all = FALSE</code> then it will be either of length zero (no match) or length one (first matching position). </p> <p><code>grepRaw(value = TRUE, all = FALSE)</code> returns a raw vector which is either empty (no match) or the matched part of <code>x</code>. </p> <p><code>grepRaw(value = TRUE, all = TRUE)</code> returns a (potentially empty) list of raw vectors corresponding to the matched parts. </p> <h3>Source</h3> <p>The TRE library of Ville Laurikari (<a href="http://laurikari.net/tre/">http://laurikari.net/tre/</a>) is used except for <code>fixed = TRUE</code>. </p> <h3>See Also</h3> <p><a href="regex.html">regular expression</a> (aka <code><a href="regex.html">regexp</a></code>) for the details of the pattern specification. </p> <p><code><a href="grep.html">grep</a></code> for matching character vectors. </p> <h3>Examples</h3> <pre> grepRaw("no match", "textText") # integer(0): no match grepRaw("adf", "adadfadfdfadadf") # 3 - the first match grepRaw("adf", "adadfadfdfadadf", all=TRUE, fixed=TRUE) ## [1] 3 6 13 -- three matches </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>