EVOLUTION-MANAGER
Edit File: str_match.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: Extract matched groups from a 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 str_match {stringr}"><tr><td>str_match {stringr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Extract matched groups from a string.</h2> <h3>Description</h3> <p>Vectorised over <code>string</code> and <code>pattern</code>. </p> <h3>Usage</h3> <pre> str_match(string, pattern) str_match_all(string, pattern) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>string</code></td> <td> <p>Input vector. Either a character vector, or something coercible to one.</p> </td></tr> <tr valign="top"><td><code>pattern</code></td> <td> <p>Pattern to look for, as defined by an ICU regular expression. See <a href="../../stringi/html/stringi-search-regex.html">stringi::stringi-search-regex</a> for more details.</p> </td></tr> </table> <h3>Value</h3> <p>For <code>str_match</code>, a character matrix. First column is the complete match, followed by one column for each capture group. For <code>str_match_all</code>, a list of character matrices. </p> <h3>See Also</h3> <p><code><a href="str_extract.html">str_extract()</a></code> to extract the complete match, <code><a href="../../stringi/html/stri_match.html">stringi::stri_match()</a></code> for the underlying implementation. </p> <h3>Examples</h3> <pre> strings <- c(" 219 733 8965", "329-293-8753 ", "banana", "595 794 7569", "387 287 6718", "apple", "233.398.9187 ", "482 952 3315", "239 923 8115 and 842 566 4692", "Work: 579-499-7527", "$1000", "Home: 543.355.3679") phone <- "([2-9][0-9]{2})[- .]([0-9]{3})[- .]([0-9]{4})" str_extract(strings, phone) str_match(strings, phone) # Extract/match all str_extract_all(strings, phone) str_match_all(strings, phone) x <- c("<a> <b>", "<a> <>", "<a>", "", NA) str_match(x, "<(.*?)> <(.*?)>") str_match_all(x, "<(.*?)>") str_extract(x, "<.*?>") str_extract_all(x, "<.*?>") </pre> <hr /><div style="text-align: center;">[Package <em>stringr</em> version 1.4.0 <a href="00Index.html">Index</a>]</div> </body></html>