Fix 3 typos in regexps (#1428)

This commit is contained in:
Peter Baumgartner 2023-04-17 14:07:22 +02:00 committed by GitHub
parent 66394d2dcd
commit cbcf1e0d8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -51,7 +51,7 @@ str_view(fruit, "berry")
```
Letters and numbers match exactly and are called **literal characters**.
Most punctuation characters, like `.`, `+`, `*`, `[`, `],` and `?`, have special meanings[^regexps-2] and are called **meta-characters**. For example, `.`
Most punctuation characters, like `.`, `+`, `*`, `[`, `],` and `?`, have special meanings[^regexps-2] and are called **metacharacters**. For example, `.`
will match any character[^regexps-3], so `"a."` will match any string that contains an "a" followed by another character
:
@ -347,7 +347,7 @@ str_view(c("abc", "a.c", "a*c", "a c"), ".[*]c")
### Anchors
By default, regular expressions will match any part of a string.
If you want to match at the start of end you need to **anchor** the regular expression using `^` to match the start or `$` to match the end:
If you want to match at the start or end you need to **anchor** the regular expression using `^` to match the start or `$` to match the end:
```{r}
str_view(fruit, "^a")
@ -654,7 +654,7 @@ str_view(sentences, "^The")
```
Because that pattern also matches sentences starting with words like `They` or `These`.
We need to make sure that the "e" is the last letter in the word, which we can do by adding adding a word boundary:
We need to make sure that the "e" is the last letter in the word, which we can do by adding a word boundary:
```{r}
str_view(sentences, "^The\\b")