EVOLUTION-MANAGER
Edit File: aregexec.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: Approximate String Match Positions</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 aregexec {utils}"><tr><td>aregexec {utils}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Approximate String Match Positions</h2> <h3>Description</h3> <p>Determine positions of approximate string matches. </p> <h3>Usage</h3> <pre> aregexec(pattern, text, max.distance = 0.1, costs = NULL, ignore.case = FALSE, fixed = FALSE, useBytes = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>pattern</code></td> <td> <p>a non-empty character string or a character string containing a regular expression (for <code>fixed = FALSE</code>) to be matched. Coerced by <code><a href="../../base/html/character.html">as.character</a></code> to a string if possible.</p> </td></tr> <tr valign="top"><td><code>text</code></td> <td> <p>character vector where matches are sought. Coerced by <code><a href="../../base/html/character.html">as.character</a></code> to a character vector if possible.</p> </td></tr> <tr valign="top"><td><code>max.distance</code></td> <td> <p>maximum distance allowed for a match. See <code><a href="../../base/html/agrep.html">agrep</a></code>.</p> </td></tr> <tr valign="top"><td><code>costs</code></td> <td> <p>cost of transformations. See <code><a href="../../base/html/agrep.html">agrep</a></code>.</p> </td></tr> <tr valign="top"><td><code>ignore.case</code></td> <td> <p>a logical. If <code>TRUE</code>, case is ignored for computing the distances.</p> </td></tr> <tr valign="top"><td><code>fixed</code></td> <td> <p>If <code>TRUE</code>, the pattern is matched literally (as is). Otherwise (default), it is matched as a regular expression.</p> </td></tr> <tr valign="top"><td><code>useBytes</code></td> <td> <p>a logical. If <code>TRUE</code> comparisons are byte-by-byte rather than character-by-character.</p> </td></tr> </table> <h3>Details</h3> <p><code>aregexec</code> provides a different interface to approximate string matching than <code><a href="../../base/html/agrep.html">agrep</a></code> (along the lines of the interfaces to exact string matching provided by <code><a href="../../base/html/grep.html">regexec</a></code> and <code><a href="../../base/html/grep.html">grep</a></code>). </p> <p>Note that by default, <code><a href="../../base/html/agrep.html">agrep</a></code> performs literal matches, whereas <code>aregexec</code> performs regular expression matches. </p> <p>See <code><a href="../../base/html/agrep.html">agrep</a></code> and <code><a href="adist.html">adist</a></code> for more information about approximate string matching and distances. </p> <p>Comparisons are byte-by-byte if <code>pattern</code> or any element of <code>text</code> is marked as <code>"bytes"</code>. </p> <h3>Value</h3> <p>A list of the same length as <code>text</code>, each element of which is either <i>-1</i> if there is no match, or a sequence of integers with the starting positions of the match and all substrings corresponding to parenthesized subexpressions of <code>pattern</code>, with attribute <code>"match.length"</code> an integer vector giving the lengths of the matches (or <i>-1</i> for no match). </p> <h3>See Also</h3> <p><code><a href="../../base/html/regmatches.html">regmatches</a></code> for extracting the matched substrings. </p> <h3>Examples</h3> <pre> ## Cf. the examples for agrep. x <- c("1 lazy", "1", "1 LAZY") aregexec("laysy", x, max.distance = 2) aregexec("(lay)(sy)", x, max.distance = 2) aregexec("(lay)(sy)", x, max.distance = 2, ignore.case = TRUE) m <- aregexec("(lay)(sy)", x, max.distance = 2) regmatches(x, m) </pre> <hr /><div style="text-align: center;">[Package <em>utils</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>