diff --git a/.nojekyll b/.nojekyll index 77730453..fd9ec2e9 100644 --- a/.nojekyll +++ b/.nojekyll @@ -1 +1 @@ -f1788b49 \ No newline at end of file +6f992183 \ No newline at end of file diff --git a/html/images/logo-stringr.png b/html/images/logo-stringr.png index c485eb3e..d4d4f843 100644 Binary files a/html/images/logo-stringr.png and b/html/images/logo-stringr.png differ diff --git a/html/strings.html b/html/strings.html index 4691185d..f4fea6c0 100644 --- a/html/strings.html +++ b/html/strings.html @@ -315,7 +315,7 @@

Join and Split

str_dup(fruit, times = 2)
-
  • str_split_fixed(string, pattern, n): Split a vector of strings into a matrix of substrings (splitting at occurrences of a pattern match). Also str_split() to return a list of substrings and str_split_n() to return the nth substring.

    +
  • str_split_fixed(string, pattern, n): Split a vector of strings into a matrix of substrings (splitting at occurrences of a pattern match). Also str_split() to return a list of substrings and str_split_i() to return the ith substring.

    str_split_fixed(sentences, " ", n = 3)
  • @@ -903,7 +903,7 @@

    Groups


    CC BY SA Posit Software, PBC • info@posit.coposit.co

    Learn more at stringr.tidyverse.org.

    -

    Updated: 2024-05.

    +

    Updated: 2024-06.

    packageVersion("stringr")
    diff --git a/index.html b/index.html index f8ac60cc..b3679f3b 100644 --- a/index.html +++ b/index.html @@ -214,7 +214,7 @@

    Posit Cheatsheets

    -
    + -
    + -
    + -
    + -
    + -
    + -
    + -
    + -
    + -
    + -
    + -
    + -
    + -
    + -
    + -
    + -
    + -
    +

    Hex logo for sparklyr - Neon shooting stars of various shapes and sizes flying across a black and grey background.

    diff --git a/pngs/strings.png b/pngs/strings.png index b1b11315..16a7e1ea 100644 Binary files a/pngs/strings.png and b/pngs/strings.png differ diff --git a/search.json b/search.json index cd0cfe5e..17cb7146 100644 --- a/search.json +++ b/search.json @@ -1341,7 +1341,7 @@ "href": "html/strings.html#join-and-split", "title": "String manipulation with stringr :: Cheatsheet", "section": "Join and Split", - "text": "Join and Split\n\nstr_c(..., sep = \"\", collapse = NULL): Join multiple strings into a single string.\n\nstr_c(letters, LETTERS)\n\nstr_flatten(string, collapse = \"\"): Combines into a single string, separated by collapse.\n\nstr_flatten(fruit, \", \")\n\nstr_dup(string, times): Repeat strings times times. Also str_unique() to remove duplicates.\n\nstr_dup(fruit, times = 2)\n\nstr_split_fixed(string, pattern, n): Split a vector of strings into a matrix of substrings (splitting at occurrences of a pattern match). Also str_split() to return a list of substrings and str_split_n() to return the nth substring.\n\nstr_split_fixed(sentences, \" \", n = 3)\n\nstr_glue(..., .sep = \"\", .envir = parent.frame()): Create a string from strings and {expressions} to evaluate.\n\nstr_glue(\"Pi is {pi}\")\n\nstr_glue_data(.x, ..., .sep = \"\", .envir = parent.frame(), .na = \"NA\"): Use a data frame, list, or environment to create a string from strings and {expressions} to evaluate.\n\nstr_glue_data(mtcars, \"{rownames(mtcars)} has {hp} hp\")" + "text": "Join and Split\n\nstr_c(..., sep = \"\", collapse = NULL): Join multiple strings into a single string.\n\nstr_c(letters, LETTERS)\n\nstr_flatten(string, collapse = \"\"): Combines into a single string, separated by collapse.\n\nstr_flatten(fruit, \", \")\n\nstr_dup(string, times): Repeat strings times times. Also str_unique() to remove duplicates.\n\nstr_dup(fruit, times = 2)\n\nstr_split_fixed(string, pattern, n): Split a vector of strings into a matrix of substrings (splitting at occurrences of a pattern match). Also str_split() to return a list of substrings and str_split_i() to return the ith substring.\n\nstr_split_fixed(sentences, \" \", n = 3)\n\nstr_glue(..., .sep = \"\", .envir = parent.frame()): Create a string from strings and {expressions} to evaluate.\n\nstr_glue(\"Pi is {pi}\")\n\nstr_glue_data(.x, ..., .sep = \"\", .envir = parent.frame(), .na = \"NA\"): Use a data frame, list, or environment to create a string from strings and {expressions} to evaluate.\n\nstr_glue_data(mtcars, \"{rownames(mtcars)} has {hp} hp\")" }, { "objectID": "html/strings.html#manage-lengths", @@ -1369,7 +1369,7 @@ "href": "html/strings.html#regular-expressions", "title": "String manipulation with stringr :: Cheatsheet", "section": "Regular Expressions", - "text": "Regular Expressions\nRegular expressions, or regexps, are a concise language for describing patterns in strings.\n\nNeed to Know\nPattern arguments in stringr are interpreted as regular expressions after any special characters have been parsed.\nIn R, you write regular expressions as strings, sequences of characters surrounded by quotes(\"\") or single quotes ('').\nSome characters cannot be directly represented in an R string. These must be represented as special characters, sequences of characters that have a specific meaning, e.g. \\\\ represents \\, \\\" represents \", and \\n represents a new line. Run ?\"'\" to see a complete list.\nBecause of this, whenever a \\ appears in a regular expression, you must write it as \\\\ in the string that represents the regular expression.\nUse writeLines() to see how R views your string after all special characters have been parsed.\nFor example, writeLines(\"\\\\.\") will be parsed as \\.\nand writeLines(\"\\\\ is a backslash\") will be parsed as \\ is a backslash.\n\n\nInterpretation\nPatterns in stringr are interpreted as regexs. To change this default, wrap the pattern in one of:\n\nregex(pattern, ignore_case = FALSE, multiline = FALSE, comments = FALSE, dotall = FALSE, ...): Modifies a regex to ignore cases, match end of lines as well as end of strings, allow R comments within regexs, and/or to have . match everthing including \\n.\n\nstr_detect(\"I\", regex(\"i\", TRUE))\n\nfixed(): Matches raw bytes but will miss some characters that can be represented in multiple ways (fast).\n\nstr_detect(\"\\u0130\", fixed(\"i\"))\n\ncoll(): Matches raw bytes and will use locale specific collation rules to recognize characters that can be represented in multiple ways (slow).\n\nstr_detect(\"\\u0130\", coll(\"i\", TRUE, locale = \"tr\"))\n\nboundary(): Matches boundaries between characters, line_breaks, sentences, or words.\n\nstr_split(sentences, boundary(\"word\"))\n\n\n\n\nMatch Characters\n\nsee <- function(rx) str_view(\"abc ABC 123\\t.!?\\\\(){}\\n\", rx)\n\n\n1Many base R functions require classes to be wrapped in a second set of [ ], e.g. [[:digit:]]\n\n\n\n\n\n\n\n\n\nstring\n(type this)\nregex\n(to mean this)\nmatches\n(which matches this)\nexample\nexample output (highlighted characters are in <>)\n\n\n\n\n\na (etc.)\na (etc.)\nsee(\"a\")\n<a>bc ABC 123\\t.!?\\(){}\\n\n\n\n\\\\.\n\\.\n.\nsee(\"\\\\.\")``\nabc ABC 123\\t<.>!?\\(){}\\n\n\n\n\\\\!\n\\!\n!\nsee(\"\\\\!\")\nabc ABC 123\\t.<!>?\\(){}\\n\n\n\n\\\\?\n\\?\n?\nsee(\"\\\\?\")\nabc ABC 123\\t.!<?>\\(){}\\n\n\n\n\\\\\\\\\n\\\\\n\\\nsee(\"\\\\\\\\\")\nabc ABC 123\\t.!?<\\>(){}\\n\n\n\n\\\\(\n\\(\n(\nsee(\"\\\\(\")\nabc ABC 123\\t.!?\\<(>){}\\n\n\n\n\\\\)\n\\)\n)\nsee(\"\\\\)\")\nabc ABC 123\\t.!?\\(<)>{}\\n\n\n\n\\\\{\n\\{\n{\nsee(\"\\\\{\")\nabc ABC 123\\t.!?\\()<{>}\\n\n\n\n\\\\}\n\\}\n}\nsee(\"\\\\}\")\nabc ABC 123\\t.!?\\(){<}>\\n\n\n\n\\\\n\n\\n\nnew line (return)\nsee(\"\\\\n\")\nabc ABC 123\\t.!?\\(){}<\\n>\n\n\n\\\\t\n\\t\ntab\nsee(\"\\\\t\")\nabc ABC 123<\\t>.!?\\(){}\\n\n\n\n\\\\s\n\\s\nany whitespace\n(\\S for non-whitespaces)\nsee(\"\\\\s\")\nabc< >ABC< >123<\\t>.!?\\(){}<\\n>\n\n\n\\\\d\n\\d\nany digit\n(\\D for non-digits)\nsee(\"\\\\d\")\nabc ABC <1><2><3>\\t.!?\\(){}\\n\n\n\n\\\\w\n\\w\nany word character\n(\\W for non-word characters)\nsee(\"\\\\w\")\n<a><b><c> <A><B><C> <1><2><3>\\t.!?\\(){}\\n\n\n\n\\\\b\n\\b\nword boundaries\nsee(\"\\\\b\")\n<>abc<> <>ABC<> <>123<>\\t.!?\\(){}\\n\n\n\n\n[:digit:]1\ndigits\nsee(\"[:digit:]\")\nabc ABC <1><2><3>\\t.!?\\(){}\\n\n\n\n\n[:alpha:]1\nletters\nsee(\"[:alpha:]\")\n<a><b><c> <A><B><C> 123\\t.!?\\(){}\\n\n\n\n\n[:lower:]1\nlowercase letters\nsee(\"[:lower:]\")\n<a><b><c> ABC 123\\t.!?\\(){}\\n\n\n\n\n[:upper:]1\nuppercase letters\nsee(\"[:upper:]\")\nabc <A><B><C> 123\\t.!?\\(){}\\n\n\n\n\n[:alnum:]1\nletters and numbers\nsee(\"[:alnum:]\")\n<a><b><c> <A><B><C> <1><2><3>\\t.!?\\(){}\\n\n\n\n\n[:punct:]1\npunctuation\nsee(\"[:punct:]\")\nabc ABC 123\\t<.><!><?><\\><(><)><{><}>\\n\n\n\n\n[:graph:]1\nletters, numbers, and punctuation\nsee(\"[:graph:]\")\n<a><b><c> <A><B><C> <1><2><3>\\t<.><!><?><\\><(><)><{><}>\\n\n\n\n\n[:space:]1\nspace characters (i.e. \\s)\nsee(\"[:space:]\")\nabc< >ABC< >123<\\t>.!?\\(){}<\\n>\n\n\n\n[:blank:]1\nspace and tab (but not new line)\nsee(\"[:blank:]\")\nabc< >ABC< >123<\\t>.!?\\(){}\\n\n\n\n\n.\nevery character except a new line\nsee(\".\")\n<a><b><c>< ><A><B><C>< ><1><2><3><\\t><.><!><?><\\><(><)><{><}><\\n>\n\n\n\n\nClasses\n\nThe [:space:] class includes new line, and the [:blank:] class\n\nThe [:blank:] class includes space and tab (\\t)\n\nThe [:graph:] class contains all non-space characters, including [:punct:], [:symbol:], [:alnum:], [:digit:], [:alpha:], [:lower:], and [:upper:]\n\n[:punct:] contains punctuation: . , : ; ? ! / * @ # - _ \" [ ] { } ( )\n[:symbol:] contains symbols: | ` = + ^ ~ < > $\n[:alnum:] contains alphanumeric characters, including [:digit:], [:alpha:], [:lower:], and [:upper:]\n\n[:digit:] contains the digits 0 through 9\n[:alpha:] contains letters, including [:upper:] and [:lower:]\n\n[:upper:] contains uppercase letters and [:lower:] contains lowercase letters\n\n\n\nThe regex . contains all characters in the above classes, except new line.\n\n\n\n\nAlternates\nalt <- function(rx) str_view(\"abcde\", rx)\n\nAlternates\n\n\n\n\n\n\n\n\nregexp\nmatches\nexample\nexample output\n(highlighted characters are in <>)\n\n\n\n\nab|d\nor\nalt(\"ab|d\")\n<ab>c<d>e\n\n\n[abe]\none of\nalt(\"[abe]\"\n<a><b>cd<e>\n\n\n[^abe]\nanything but\nalt(\"[^abe]\")\nab<c><d>e\n\n\n[a-c]\nrange\nalt(\"[a-c]\")\n<a><b><c>de\n\n\n\n\n\nAnchors\nanchor <- function(rx) str_view(\"aaa\", rx)\n\nAnchors\n\n\n\n\n\nregexp | matches | example | example output\n| | | (highlighted characters are in <>)\n\n\n\n\n^a | start of string | anchor(\"^a\") | | | | <a>aa | | |\n\n\na$ | end of string | anchor(\"a$\") | | | | aa<a> | | |\n\n\n\n\n\nLook Arounds\nlook <- function(rx) str_view(\"bacad\", rx)\n\nLook arounds\n\n\n\n\n\n\n\n\nregexp\nmatches\nexample\nexample output\n(highlighted characters are in <>)\n\n\n\n\na(?=c)\nfollowed by\nlook(\"a(?=c)\")\nb<a>cad\n\n\na(?!c)\nnot followed by\nlook(\"a(?!c)\")\nbac<a>d\n\n\n(?<=b)a\npreceded by\nlook(\"(?<=b)a\")\nb<a>cad\n\n\n(?<!b)a\nnot preceded by\nlook(\"(?<!b)a\")\nbac<a>d\n\n\n\n\n\nQuantifiers\nquant <- function(rx) str_view(\".a.aa.aaa\", rx)\n\nQuantifiers\n\n\n\n\n\n\n\n\nregexp\nmatches\nexample\nexample output\n(highlighted characters are in <>)\n\n\n\n\na?\nzero or one\nquant(\"a?\")\n<>.<a><>.<a><a><>.<a><a><a><>\n\n\na*\nzero or more\nquant(\"a*\")\n<>.<a><>.<aa><>.<aaa><>\n\n\na+\none or more\nquant(\"a+\")\n.<a>.<aa>.<aaa>\n\n\na{n}\nexactly n\nquant(\"a{2}\")\n.a.<aa>.<aa>a\n\n\na{n, }\nn or more\nquant(\"a{2,}\")\n.a.<aa>.<aaa>\n\n\na{n, m}\nbetween n and m\nquant(\"a{2,4}\")\n.a.<aa>.<aaa>\n\n\n\n\n\nGroups\nref <- function(rx) str_view(\"abbaab\", rx)\nUse parentheses to set precedent (order of evaluation) and create groups\n\nGroups\n\n\n\n\n\n\n\n\nregexp\nmatches\nexample\nexample output\n(highlighted characters are in <>)\n\n\n\n\n(ab|d)e\nsets precedence\nalt(\"(ab|d)e\")\nabc<de>\n\n\n\nUse an escaped number to refer to and duplicate parentheses groups that occur earlier in a pattern. Refer to each group by its order of appearance\n\nMore groups\n\n\n\n\n\n\n\n\n\nstring\n(type this)\nregexp\n(to mean this)\nmatches\n(which matches this)\nexample\n(the result is the same as ref(\"abba\"))\nexample output\n(highlighted characters are in <>)\n\n\n\n\n\\\\1\n\\1 (etc.)\nfirst () group, etc.\nref(\"(a)(b)\\\\2\\\\1\")\n<abba>ab\n\n\n\n\nCC BY SA Posit Software, PBC • info@posit.co • posit.co\nLearn more at stringr.tidyverse.org.\nUpdated: 2024-05.\n\npackageVersion(\"stringr\")\n\n[1] '1.5.1'" + "text": "Regular Expressions\nRegular expressions, or regexps, are a concise language for describing patterns in strings.\n\nNeed to Know\nPattern arguments in stringr are interpreted as regular expressions after any special characters have been parsed.\nIn R, you write regular expressions as strings, sequences of characters surrounded by quotes(\"\") or single quotes ('').\nSome characters cannot be directly represented in an R string. These must be represented as special characters, sequences of characters that have a specific meaning, e.g. \\\\ represents \\, \\\" represents \", and \\n represents a new line. Run ?\"'\" to see a complete list.\nBecause of this, whenever a \\ appears in a regular expression, you must write it as \\\\ in the string that represents the regular expression.\nUse writeLines() to see how R views your string after all special characters have been parsed.\nFor example, writeLines(\"\\\\.\") will be parsed as \\.\nand writeLines(\"\\\\ is a backslash\") will be parsed as \\ is a backslash.\n\n\nInterpretation\nPatterns in stringr are interpreted as regexs. To change this default, wrap the pattern in one of:\n\nregex(pattern, ignore_case = FALSE, multiline = FALSE, comments = FALSE, dotall = FALSE, ...): Modifies a regex to ignore cases, match end of lines as well as end of strings, allow R comments within regexs, and/or to have . match everthing including \\n.\n\nstr_detect(\"I\", regex(\"i\", TRUE))\n\nfixed(): Matches raw bytes but will miss some characters that can be represented in multiple ways (fast).\n\nstr_detect(\"\\u0130\", fixed(\"i\"))\n\ncoll(): Matches raw bytes and will use locale specific collation rules to recognize characters that can be represented in multiple ways (slow).\n\nstr_detect(\"\\u0130\", coll(\"i\", TRUE, locale = \"tr\"))\n\nboundary(): Matches boundaries between characters, line_breaks, sentences, or words.\n\nstr_split(sentences, boundary(\"word\"))\n\n\n\n\nMatch Characters\n\nsee <- function(rx) str_view(\"abc ABC 123\\t.!?\\\\(){}\\n\", rx)\n\n\n1Many base R functions require classes to be wrapped in a second set of [ ], e.g. [[:digit:]]\n\n\n\n\n\n\n\n\n\nstring\n(type this)\nregex\n(to mean this)\nmatches\n(which matches this)\nexample\nexample output (highlighted characters are in <>)\n\n\n\n\n\na (etc.)\na (etc.)\nsee(\"a\")\n<a>bc ABC 123\\t.!?\\(){}\\n\n\n\n\\\\.\n\\.\n.\nsee(\"\\\\.\")``\nabc ABC 123\\t<.>!?\\(){}\\n\n\n\n\\\\!\n\\!\n!\nsee(\"\\\\!\")\nabc ABC 123\\t.<!>?\\(){}\\n\n\n\n\\\\?\n\\?\n?\nsee(\"\\\\?\")\nabc ABC 123\\t.!<?>\\(){}\\n\n\n\n\\\\\\\\\n\\\\\n\\\nsee(\"\\\\\\\\\")\nabc ABC 123\\t.!?<\\>(){}\\n\n\n\n\\\\(\n\\(\n(\nsee(\"\\\\(\")\nabc ABC 123\\t.!?\\<(>){}\\n\n\n\n\\\\)\n\\)\n)\nsee(\"\\\\)\")\nabc ABC 123\\t.!?\\(<)>{}\\n\n\n\n\\\\{\n\\{\n{\nsee(\"\\\\{\")\nabc ABC 123\\t.!?\\()<{>}\\n\n\n\n\\\\}\n\\}\n}\nsee(\"\\\\}\")\nabc ABC 123\\t.!?\\(){<}>\\n\n\n\n\\\\n\n\\n\nnew line (return)\nsee(\"\\\\n\")\nabc ABC 123\\t.!?\\(){}<\\n>\n\n\n\\\\t\n\\t\ntab\nsee(\"\\\\t\")\nabc ABC 123<\\t>.!?\\(){}\\n\n\n\n\\\\s\n\\s\nany whitespace\n(\\S for non-whitespaces)\nsee(\"\\\\s\")\nabc< >ABC< >123<\\t>.!?\\(){}<\\n>\n\n\n\\\\d\n\\d\nany digit\n(\\D for non-digits)\nsee(\"\\\\d\")\nabc ABC <1><2><3>\\t.!?\\(){}\\n\n\n\n\\\\w\n\\w\nany word character\n(\\W for non-word characters)\nsee(\"\\\\w\")\n<a><b><c> <A><B><C> <1><2><3>\\t.!?\\(){}\\n\n\n\n\\\\b\n\\b\nword boundaries\nsee(\"\\\\b\")\n<>abc<> <>ABC<> <>123<>\\t.!?\\(){}\\n\n\n\n\n[:digit:]1\ndigits\nsee(\"[:digit:]\")\nabc ABC <1><2><3>\\t.!?\\(){}\\n\n\n\n\n[:alpha:]1\nletters\nsee(\"[:alpha:]\")\n<a><b><c> <A><B><C> 123\\t.!?\\(){}\\n\n\n\n\n[:lower:]1\nlowercase letters\nsee(\"[:lower:]\")\n<a><b><c> ABC 123\\t.!?\\(){}\\n\n\n\n\n[:upper:]1\nuppercase letters\nsee(\"[:upper:]\")\nabc <A><B><C> 123\\t.!?\\(){}\\n\n\n\n\n[:alnum:]1\nletters and numbers\nsee(\"[:alnum:]\")\n<a><b><c> <A><B><C> <1><2><3>\\t.!?\\(){}\\n\n\n\n\n[:punct:]1\npunctuation\nsee(\"[:punct:]\")\nabc ABC 123\\t<.><!><?><\\><(><)><{><}>\\n\n\n\n\n[:graph:]1\nletters, numbers, and punctuation\nsee(\"[:graph:]\")\n<a><b><c> <A><B><C> <1><2><3>\\t<.><!><?><\\><(><)><{><}>\\n\n\n\n\n[:space:]1\nspace characters (i.e. \\s)\nsee(\"[:space:]\")\nabc< >ABC< >123<\\t>.!?\\(){}<\\n>\n\n\n\n[:blank:]1\nspace and tab (but not new line)\nsee(\"[:blank:]\")\nabc< >ABC< >123<\\t>.!?\\(){}\\n\n\n\n\n.\nevery character except a new line\nsee(\".\")\n<a><b><c>< ><A><B><C>< ><1><2><3><\\t><.><!><?><\\><(><)><{><}><\\n>\n\n\n\n\nClasses\n\nThe [:space:] class includes new line, and the [:blank:] class\n\nThe [:blank:] class includes space and tab (\\t)\n\nThe [:graph:] class contains all non-space characters, including [:punct:], [:symbol:], [:alnum:], [:digit:], [:alpha:], [:lower:], and [:upper:]\n\n[:punct:] contains punctuation: . , : ; ? ! / * @ # - _ \" [ ] { } ( )\n[:symbol:] contains symbols: | ` = + ^ ~ < > $\n[:alnum:] contains alphanumeric characters, including [:digit:], [:alpha:], [:lower:], and [:upper:]\n\n[:digit:] contains the digits 0 through 9\n[:alpha:] contains letters, including [:upper:] and [:lower:]\n\n[:upper:] contains uppercase letters and [:lower:] contains lowercase letters\n\n\n\nThe regex . contains all characters in the above classes, except new line.\n\n\n\n\nAlternates\nalt <- function(rx) str_view(\"abcde\", rx)\n\nAlternates\n\n\n\n\n\n\n\n\nregexp\nmatches\nexample\nexample output\n(highlighted characters are in <>)\n\n\n\n\nab|d\nor\nalt(\"ab|d\")\n<ab>c<d>e\n\n\n[abe]\none of\nalt(\"[abe]\"\n<a><b>cd<e>\n\n\n[^abe]\nanything but\nalt(\"[^abe]\")\nab<c><d>e\n\n\n[a-c]\nrange\nalt(\"[a-c]\")\n<a><b><c>de\n\n\n\n\n\nAnchors\nanchor <- function(rx) str_view(\"aaa\", rx)\n\nAnchors\n\n\n\n\n\nregexp | matches | example | example output\n| | | (highlighted characters are in <>)\n\n\n\n\n^a | start of string | anchor(\"^a\") | | | | <a>aa | | |\n\n\na$ | end of string | anchor(\"a$\") | | | | aa<a> | | |\n\n\n\n\n\nLook Arounds\nlook <- function(rx) str_view(\"bacad\", rx)\n\nLook arounds\n\n\n\n\n\n\n\n\nregexp\nmatches\nexample\nexample output\n(highlighted characters are in <>)\n\n\n\n\na(?=c)\nfollowed by\nlook(\"a(?=c)\")\nb<a>cad\n\n\na(?!c)\nnot followed by\nlook(\"a(?!c)\")\nbac<a>d\n\n\n(?<=b)a\npreceded by\nlook(\"(?<=b)a\")\nb<a>cad\n\n\n(?<!b)a\nnot preceded by\nlook(\"(?<!b)a\")\nbac<a>d\n\n\n\n\n\nQuantifiers\nquant <- function(rx) str_view(\".a.aa.aaa\", rx)\n\nQuantifiers\n\n\n\n\n\n\n\n\nregexp\nmatches\nexample\nexample output\n(highlighted characters are in <>)\n\n\n\n\na?\nzero or one\nquant(\"a?\")\n<>.<a><>.<a><a><>.<a><a><a><>\n\n\na*\nzero or more\nquant(\"a*\")\n<>.<a><>.<aa><>.<aaa><>\n\n\na+\none or more\nquant(\"a+\")\n.<a>.<aa>.<aaa>\n\n\na{n}\nexactly n\nquant(\"a{2}\")\n.a.<aa>.<aa>a\n\n\na{n, }\nn or more\nquant(\"a{2,}\")\n.a.<aa>.<aaa>\n\n\na{n, m}\nbetween n and m\nquant(\"a{2,4}\")\n.a.<aa>.<aaa>\n\n\n\n\n\nGroups\nref <- function(rx) str_view(\"abbaab\", rx)\nUse parentheses to set precedent (order of evaluation) and create groups\n\nGroups\n\n\n\n\n\n\n\n\nregexp\nmatches\nexample\nexample output\n(highlighted characters are in <>)\n\n\n\n\n(ab|d)e\nsets precedence\nalt(\"(ab|d)e\")\nabc<de>\n\n\n\nUse an escaped number to refer to and duplicate parentheses groups that occur earlier in a pattern. Refer to each group by its order of appearance\n\nMore groups\n\n\n\n\n\n\n\n\n\nstring\n(type this)\nregexp\n(to mean this)\nmatches\n(which matches this)\nexample\n(the result is the same as ref(\"abba\"))\nexample output\n(highlighted characters are in <>)\n\n\n\n\n\\\\1\n\\1 (etc.)\nfirst () group, etc.\nref(\"(a)(b)\\\\2\\\\1\")\n<abba>ab\n\n\n\n\nCC BY SA Posit Software, PBC • info@posit.co • posit.co\nLearn more at stringr.tidyverse.org.\nUpdated: 2024-06.\n\npackageVersion(\"stringr\")\n\n[1] '1.5.1'" }, { "objectID": "index.html", diff --git a/sitemap.xml b/sitemap.xml index 0ba12100..0b1e084c 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -2,86 +2,86 @@ https://rstudio.github.io/cheatsheets/translations.html - 2024-06-16T20:51:53.544Z + 2024-06-17T10:06:23.127Z https://rstudio.github.io/cheatsheets/html/tidyr.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.251Z https://rstudio.github.io/cheatsheets/html/sparklyr.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.247Z https://rstudio.github.io/cheatsheets/html/shiny-python.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.247Z https://rstudio.github.io/cheatsheets/html/rmarkdown.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.247Z https://rstudio.github.io/cheatsheets/html/quarto.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.247Z https://rstudio.github.io/cheatsheets/html/plumber.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.247Z https://rstudio.github.io/cheatsheets/html/lubridate.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.247Z https://rstudio.github.io/cheatsheets/html/factors.html - 2024-06-16T20:51:51.644Z + 2024-06-17T10:06:21.223Z https://rstudio.github.io/cheatsheets/html/data-transformation.html - 2024-06-16T20:51:51.640Z + 2024-06-17T10:06:21.223Z https://rstudio.github.io/cheatsheets/contributed-cheatsheets.html - 2024-06-16T20:51:51.576Z + 2024-06-17T10:06:21.155Z https://rstudio.github.io/cheatsheets/html/data-import.html - 2024-06-16T20:51:51.640Z + 2024-06-17T10:06:21.223Z https://rstudio.github.io/cheatsheets/html/data-visualization.html - 2024-06-16T20:51:51.640Z + 2024-06-17T10:06:21.223Z https://rstudio.github.io/cheatsheets/html/keras.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.247Z https://rstudio.github.io/cheatsheets/html/package-development.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.247Z https://rstudio.github.io/cheatsheets/html/purrr.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.247Z https://rstudio.github.io/cheatsheets/html/reticulate.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.247Z https://rstudio.github.io/cheatsheets/html/rstudio-ide.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.247Z https://rstudio.github.io/cheatsheets/html/shiny.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.247Z https://rstudio.github.io/cheatsheets/html/strings.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.251Z https://rstudio.github.io/cheatsheets/index.html - 2024-06-16T20:51:51.668Z + 2024-06-17T10:06:21.251Z diff --git a/strings.pdf b/strings.pdf index 8cef4fa7..1524bf3e 100644 Binary files a/strings.pdf and b/strings.pdf differ diff --git a/translations/portuguese/strings_pt_br.pdf b/translations/portuguese/strings_pt_br.pdf index d549720c..028b283a 100644 Binary files a/translations/portuguese/strings_pt_br.pdf and b/translations/portuguese/strings_pt_br.pdf differ