Fix/regexps probably typos (#1480)

* a typo

* a typo

* probably a typo

* a typo

* b$ means ending with b

* Update regexps.qmd

---------

Co-authored-by: Mine Cetinkaya-Rundel <cetinkaya.mine@gmail.com>
This commit is contained in:
Mitsuo Shiota 2023-05-21 13:07:34 +09:00 committed by GitHub
parent 6c9cfea1e0
commit 6124b65098
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 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 **metacharacters**. 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
:
@ -283,10 +283,10 @@ If the match fails, you can use `too_short = "debug"` to figure out what went wr
## Pattern details
Now that you understand the basics of the pattern language and how to use it with some stringr and tidyr functions, its time to dig into more of the details.
Now that you understand the basics of the pattern language and how to use it with some stringr and tidyr functions, it's time to dig into more of the details.
First, we'll start with **escaping**, which allows you to match metacharacters that would otherwise be treated specially.
Next, you'll learn about **anchors** which allow you to match the start or end of the string.
Then, you'll more learn about **character classes** and their shortcuts which allow you to match any character from a set.
Then, you'll learn more about **character classes** and their shortcuts which allow you to match any character from a set.
Next, you'll learn the final details of **quantifiers** which control how many times a pattern can match.
Then, we have to cover the important (but complex) topic of **operator precedence** and parentheses.
And we'll finish off with some details of **grouping** components of the pattern.
@ -330,7 +330,7 @@ str_view(x, "\\\\")
```
Alternatively, you might find it easier to use the raw strings you learned about in @sec-raw-strings).
That lets you to avoid one layer of escaping:
That lets you avoid one layer of escaping:
```{r}
str_view(x, r"{\\}")
@ -449,7 +449,7 @@ You can also specify the number of matches precisely with `{}`:
What does `ab+` match?
Does it match "a" followed by one or more "b"s, or does it match "ab" repeated any number of times?
What does `^a|b$` match?
Does it match the complete string a or the complete string b, or does it match a string starting with a or a string starting with "b"?
Does it match the complete string a or the complete string b, or does it match a string starting with a or a string ending with b?
The answer to these questions is determined by operator precedence, similar to the PEMDAS or BEDMAS rules you might have learned in school.
You know that `a + b * c` is equivalent to `a + (b * c)` not `(a + b) * c` because `*` has higher precedence and `+` has lower precedence: you compute `*` before `+`.