-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
60 lines (43 loc) · 1.8 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
**NOTE: This is an example package mostly copied from the online edition of [R Packages (2e)](https://r-pkgs.org). All credits go to the original authors.**
# Regexcite
<!-- badges: start -->
<!-- badges: end -->
The goal of Regexcite is to make regular expressions more exciting!
It provides convenience functions to make some common tasks with string manipulation and regular expressions a bit easier.
## Installation
You can install the development version of Regexcite from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("yzchang/Regexcite")
```
## Usage
A fairly common task when dealing with strings is the need to split a single string into a plain list of many parts.
This package provides two functions `Regexcite::str_split_one()` and `Regexcite::str_split_multi()` that split a single character vector by a single character (i.e. `Regexcite::str_split_one()`) or one or more character vectors by one or more characters (i.e. `Regexcite::str_split_multi()`) into a single list of character vector(s).
## Example
Use `Regexcite::str_split_one()` when the input is know to be a single string and the pattern is a single character:
```{r example_one}
library(Regexcite)
s <- "echo:foxtrot:golf:hotel"
str_split_one(s, ':')
```
Use `Regexcite::str_split_multi()` when the input contains multiple strings or the pattern contains multiple characters:
```{r example_multi}
library(Regexcite)
fruits <- c(
"apples and oranges and pears and bananas",
"pineapples and mangos and guavas"
)
str_split_multi(fruits, " and ")
```