{"id":13776140,"url":"https://github.com/tidyverse/stringr","last_synced_at":"2025-12-17T09:49:55.106Z","repository":{"id":718529,"uuid":"365649","full_name":"tidyverse/stringr","owner":"tidyverse","description":"A fresh approach to string manipulation in R","archived":false,"fork":false,"pushed_at":"2025-11-04T22:52:35.000Z","size":7060,"stargazers_count":645,"open_issues_count":3,"forks_count":195,"subscribers_count":33,"default_branch":"main","last_synced_at":"2025-12-08T19:49:26.236Z","etag":null,"topics":["r","regular-expression","strings"],"latest_commit_sha":null,"homepage":"https://stringr.tidyverse.org","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tidyverse.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2009-11-08T22:20:08.000Z","updated_at":"2025-12-06T06:41:18.000Z","dependencies_parsed_at":"2023-07-05T15:16:59.453Z","dependency_job_id":"c80ce53e-8d96-436a-9dca-fab08066868b","html_url":"https://github.com/tidyverse/stringr","commit_stats":{"total_commits":603,"total_committers":75,"mean_commits":8.04,"dds":"0.19071310116086237","last_synced_commit":"a64b8f1ccc2506cfa4b7af7b9fa7766200eb71ac"},"previous_names":["hadley/stringr"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/tidyverse/stringr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidyverse%2Fstringr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidyverse%2Fstringr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidyverse%2Fstringr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidyverse%2Fstringr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tidyverse","download_url":"https://codeload.github.com/tidyverse/stringr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidyverse%2Fstringr/sbom","scorecard":{"id":884874,"data":{"date":"2025-08-11","repo":{"name":"github.com/tidyverse/stringr","commit":"90f8ba7fc3746c07db2d41597bcdc143b78a76d4"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.2,"checks":[{"name":"Code-Review","score":6,"reason":"Found 18/30 approved changesets -- score normalized to 6","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":3,"reason":"0 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Warn: jobLevel 'contents' permission set to 'write': .github/workflows/pkgdown.yaml:25","Warn: jobLevel 'contents' permission set to 'write': .github/workflows/pr-commands.yaml:19","Warn: jobLevel 'contents' permission set to 'write': .github/workflows/pr-commands.yaml:58","Info: topLevel permissions set to 'read-all': .github/workflows/R-CMD-check.yaml:15","Info: topLevel permissions set to 'read-all': .github/workflows/pkgdown.yaml:14","Info: topLevel permissions set to 'read-all': .github/workflows/pr-commands.yaml:9","Info: topLevel permissions set to 'read-all': .github/workflows/test-coverage.yaml:11"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/R-CMD-check.yaml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/R-CMD-check.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/R-CMD-check.yaml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/R-CMD-check.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/R-CMD-check.yaml:49: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/R-CMD-check.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/R-CMD-check.yaml:55: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/R-CMD-check.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/R-CMD-check.yaml:60: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/R-CMD-check.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pkgdown.yaml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/pkgdown.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pkgdown.yaml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/pkgdown.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pkgdown.yaml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/pkgdown.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pkgdown.yaml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/pkgdown.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pkgdown.yaml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/pkgdown.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pr-commands.yaml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/pr-commands.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pr-commands.yaml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/pr-commands.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pr-commands.yaml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/pr-commands.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pr-commands.yaml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/pr-commands.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pr-commands.yaml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/pr-commands.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pr-commands.yaml:60: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/pr-commands.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pr-commands.yaml:62: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/pr-commands.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pr-commands.yaml:66: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/pr-commands.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pr-commands.yaml:83: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/pr-commands.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test-coverage.yaml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/test-coverage.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test-coverage.yaml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/test-coverage.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test-coverage.yaml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/test-coverage.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test-coverage.yaml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/test-coverage.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test-coverage.yaml:58: update your workflow using https://app.stepsecurity.io/secureworkflow/tidyverse/stringr/test-coverage.yaml/main?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of  18 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 23 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T09:36:29.240Z","repository_id":718529,"created_at":"2025-08-24T09:36:29.240Z","updated_at":"2025-08-24T09:36:29.240Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27720801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-14T02:00:11.348Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["r","regular-expression","strings"],"created_at":"2024-08-03T18:00:17.350Z","updated_at":"2025-12-17T09:49:55.088Z","avatar_url":"https://github.com/tidyverse.png","language":"R","readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"README-\"\n)\nlibrary(stringr)\n```\n\n# stringr \u003ca href='https://stringr.tidyverse.org'\u003e\u003cimg src='man/figures/logo.png' align=\"right\" height=\"139\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/stringr)](https://cran.r-project.org/package=stringr)\n[![R-CMD-check](https://github.com/tidyverse/stringr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidyverse/stringr/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/tidyverse/stringr/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidyverse/stringr?branch=main)\n[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)\n\u003c!-- badges: end --\u003e\n\n## Overview\n\nStrings are not glamorous, high-profile components of R, but they do play a big role in many data cleaning and preparation tasks. The stringr package provides a cohesive set of functions designed to make working with strings as easy as possible. If you're not familiar with strings, the best place to start is the [chapter on strings](https://r4ds.hadley.nz/strings) in R for Data Science.\n\nstringr is built on top of [stringi](https://github.com/gagolews/stringi), which uses the [ICU](https://icu.unicode.org) C library to provide fast, correct implementations of common string manipulations. stringr focusses on the most important and commonly used string manipulation functions whereas stringi provides a comprehensive set covering almost anything you can imagine. If you find that stringr is missing a function that you need, try looking in stringi. Both packages share similar conventions, so once you've mastered stringr, you should find stringi similarly easy to use.\n\n## Installation\n\n```r\n# The easiest way to get stringr is to install the whole tidyverse:\ninstall.packages(\"tidyverse\")\n\n# Alternatively, install just stringr:\ninstall.packages(\"stringr\")\n```\n\n## Cheatsheet\n\n\u003ca href=\"https://github.com/rstudio/cheatsheets/blob/main/strings.pdf\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/rstudio/cheatsheets/main/pngs/thumbnails/strings-cheatsheet-thumbs.png\" width=\"630\" height=\"242\"/\u003e\u003c/a\u003e  \n\n## Usage\n\nAll functions in stringr start with `str_` and take a vector of strings as the first argument:\n\n```{r}\nx \u003c- c(\"why\", \"video\", \"cross\", \"extra\", \"deal\", \"authority\")\nstr_length(x) \nstr_c(x, collapse = \", \")\nstr_sub(x, 1, 2)\n```\n\nMost string functions work with regular expressions, a concise language for describing patterns of text. For example, the regular expression `\"[aeiou]\"` matches any single character that is a vowel:\n\n```{r}\nstr_subset(x, \"[aeiou]\")\nstr_count(x, \"[aeiou]\")\n```\n\nThere are seven main verbs that work with patterns:\n\n*   `str_detect(x, pattern)` tells you if there's any match to the pattern:\n    ```{r}\n    str_detect(x, \"[aeiou]\")\n    ```\n    \n*   `str_count(x, pattern)` counts the number of patterns:\n    ```{r}\n    str_count(x, \"[aeiou]\")\n    ```\n\n*   `str_subset(x, pattern)` extracts the matching components:\n    ```{r}\n    str_subset(x, \"[aeiou]\")\n    ```\n\n*   `str_locate(x, pattern)` gives the position of the match:\n    ```{r}\n    str_locate(x, \"[aeiou]\")\n    ```\n\n*   `str_extract(x, pattern)` extracts the text of the match:\n    ```{r}\n    str_extract(x, \"[aeiou]\")\n    ```\n\n*   `str_match(x, pattern)` extracts parts of the match defined by parentheses:\n    ```{r}\n    # extract the characters on either side of the vowel\n    str_match(x, \"(.)[aeiou](.)\")\n    ```\n\n*   `str_replace(x, pattern, replacement)` replaces the matches with new text:\n    ```{r}\n    str_replace(x, \"[aeiou]\", \"?\")\n    ```\n\n*   `str_split(x, pattern)` splits up a string into multiple pieces:\n    ```{r}\n    str_split(c(\"a,b\", \"c,d,e\"), \",\")\n    ```\n\nAs well as regular expressions (the default), there are three other pattern matching engines:\n\n* `fixed()`: match exact bytes\n* `coll()`: match human letters\n* `boundary()`: match boundaries\n\n## RStudio Addin\n\nThe [RegExplain RStudio addin](https://www.garrickadenbuie.com/project/regexplain/) provides a friendly interface for working with regular expressions and functions from stringr. This addin allows you to interactively build your regexp, check the output of common string matching functions, consult the interactive help pages, or use the included resources to learn regular expressions.\n\nThis addin can easily be installed with devtools:\n\n```r\n# install.packages(\"devtools\")\ndevtools::install_github(\"gadenbuie/regexplain\")\n```\n\n## Compared to base R\n\nR provides a solid set of string operations, but because they have grown organically over time, they can be inconsistent and a little hard to learn. Additionally, they lag behind the string operations in other programming languages, so that some things that are easy to do in languages like Ruby or Python are rather hard to do in R. \n\n* Uses consistent function and argument names. The first argument is always\n  the vector of strings to modify, which makes stringr work particularly well\n  in conjunction with the pipe:\n  \n    ```{r}\n    letters %\u003e%\n      .[1:10] %\u003e% \n      str_pad(3, \"right\") %\u003e%\n      str_c(letters[2:11])\n    ```\n\n* Simplifies string operations by eliminating options that you don't need\n  95% of the time.\n\n* Produces outputs than can easily be used as inputs. This includes ensuring\n  that missing inputs result in missing outputs, and zero length inputs\n  result in zero length outputs.\n  \nLearn more in `vignette(\"from-base\")`\n","funding_links":[],"categories":["Table of Contents","R"],"sub_categories":["Data manipulation"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidyverse%2Fstringr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftidyverse%2Fstringr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidyverse%2Fstringr/lists"}