phone_numbers <- c("515 111 2244", 
                   "310 549 6892", 
                   "474 234 7548")
str_view(phone_numbers, "(\\d)\\d\\1")[1] │ <515> <111> 2244
[3] │ <474> 234 7548
STAT 220
Preceding characters are matched …
* = 0 or more? = 0 or 1+ = 1 or more{n} = exactly n timesMatching character types
\\d = digit\\s = white space\\w = alphanumeric\\t = tab\\n = newlinestringr cheatsheet
useful when you want to match a pattern a specific number of times
{n, } = n or more times
{, m} = at most m times
{n, m} = between n & m times
useful for matching patterns more flexibly
[abc] = one of a, b, or c
[e-z] = a letter from e to z
[^abc] = anything other than a, b, or c
Use escaped numbers (\\1, \\2, etc) to repeat a group based on position
Which numbers have the same 1st and 3rd digits?
(\\d) matches a single digit (from 0 to 9) and captures it into a capturing group. \\d matches another single digit (from 0 to 9). \\1 matches the same digit as the first captured group.
str_view_all()str_replace_all()str_extract_all()Repetition using ?
Repetition using +
Repetition using *
[1] "ONE SMALL STEP FOR MAN, ONE GIANT LEAP FOR MANKIND"

ca12-yourusername repository from Github10:00
Lookaround operators
 
Source: click here
Positive look ahead operator
x(?=[y])will findxwhen it comes beforey
Negative version is
x(?![y])(xwhen it comes before something that isn’ty)
Positive look ahead operator
x(?=[y])will findxwhen it comes beforey
Negative version is
x(?![y])(xwhen it comes before something that isn’ty)
Positive look behind operator
(?<=[x])ywill findywhen it followsx
Negative version is
(?<![x])y(ywhen it does not followx)
Positive look behind operator
(?<=[x])ywill findywhen it followsx
Negative version is
(?<![x])y(ywhen it does not followx)

10:00