diff --git a/regexps.qmd b/regexps.qmd index fa48a88..4e60814 100644 --- a/regexps.qmd +++ b/regexps.qmd @@ -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")