Skip to content

Commit

Permalink
Fix 3 typos in regexps (hadley#1428)
Browse files Browse the repository at this point in the history
  • Loading branch information
petzi53 authored Apr 17, 2023
1 parent 66394d2 commit cbcf1e0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions regexps.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
:

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit cbcf1e0

Please sign in to comment.