suppressPackageStartupMessages(library("tidyverse"))
package 㤼㸱tidyverse㤼㸲 was built under R version 3.6.3
1. Explain why each of these strings don’t match a \
: "\"
, "\\"
, "\\\"
.
"\"
: This will escape the next character in the R string.
"\\"
: This will resolve to \
in the regular expression, which will escape the next character in the regular expression.
"\\\"
: The first two backslashes will resolve to a literal backslash in the regular expression, the third will escape the next character. So in the regular expression, this will escape some escaped character.
2. How would you match the sequence "'\
?
str_view("\"'\\", "\"'\\\\", match = TRUE)
Registered S3 methods overwritten by 'htmltools':
method from
print.html tools:rstudio
print.shiny.tag tools:rstudio
print.shiny.tag.list tools:rstudio
Registered S3 method overwritten by 'htmlwidgets':
method from
print.htmlwidget tools:rstudio
3. What patterns will the regular expression \..\..\..
match? How would you represent it as a string?
It will match any patterns that are a dot followed by any character, repeated three times.
str_view(c(".a.b.c", ".a.b", "....."), c("\\..\\..\\.."), match = TRUE)
LS0tDQp0aXRsZTogIkJhc2ljIG1hdGNoZXMiDQpvdXRwdXQ6IA0KICBodG1sX25vdGVib29rOg0KICAgIHRvYzogdHJ1ZQ0KICAgIHRvY19mbG9hdDogdHJ1ZQ0KLS0tDQoNCmBgYHtyfQ0Kc3VwcHJlc3NQYWNrYWdlU3RhcnR1cE1lc3NhZ2VzKGxpYnJhcnkoInRpZHl2ZXJzZSIpKQ0KYGBgDQoNCiMjIyAxLiBFeHBsYWluIHdoeSBlYWNoIG9mIHRoZXNlIHN0cmluZ3MgZG9u4oCZdCBtYXRjaCBhIGBcYDogYCJcImAsIGAiXFwiYCwgYCJcXFwiYC4NCg0KIC0gYCJcImA6IFRoaXMgd2lsbCBlc2NhcGUgdGhlIG5leHQgY2hhcmFjdGVyIGluIHRoZSBSIHN0cmluZy4NCiAtIGAiXFwiYDogVGhpcyB3aWxsIHJlc29sdmUgdG8gYFxgIGluIHRoZSByZWd1bGFyIGV4cHJlc3Npb24sIHdoaWNoIHdpbGwgZXNjYXBlIHRoZSBuZXh0IGNoYXJhY3RlciBpbiB0aGUgcmV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