str_which_between: Which lines fall in between a delimeter pattern

View source: R/rmarkdown.R

str_which_betweenR Documentation

Which lines fall in between a delimeter pattern

Description

Which lines fall in between a delimeter pattern

Usage

str_which_between(string, pattern)

Arguments

string

a character vector

pattern

a regular expression pattern to look for

Value

the lines that are contained between pairs of delimiter patterns

Examples

string <- "
```{r}
# some code
```

Here is more code.

```markdown
**bold!**
```
"

lines <- unlist(strsplit(string, "\n"))
str_which_between(lines, "^```")

tjmahr/tjmisc documentation built on Feb. 8, 2023, 12:21 p.m.