data <- read.csv("https://raw.githubusercontent.com/yvargas1590/data607/main/recent-grads.csv")
data_or_stats_major <- grep("DATA|STATISTICS", data$major, value = TRUE, ignore.case = TRUE)
#2 Write code that transforms the data below:
data <- c("bell pepper", "bilberry", "blackberry", "blood orange", "blueberry", "cantaloupe", "chili pepper", "cloudberry", "elderberry", "lime", "lychee", "mulberry", "olive", "salal berry")
print(data)
## [1] "bell pepper" "bilberry" "blackberry" "blood orange" "blueberry"
## [6] "cantaloupe" "chili pepper" "cloudberry" "elderberry" "lime"
## [11] "lychee" "mulberry" "olive" "salal berry"
#3 Describe, in words, what these expressions will match:
(.)\1\1: This expression will match any character (represented by
“.)”) followed by the same character repeated two more times. For
example, it will match “aaa” or “111”.
“(.)(.)\2\1”: This expression will match any two characters
(represented by “(.)” and “(.)”) followed by the same second character
and then the same first character. For example, it will match “abba” or
“2424”.
(..)\1: This expression will match any two characters (represented
by “..”) repeated exactly twice. For example, it will match “aa” or
“99”.
“(.).\1.\1”: This expression will match any character (represented
by “(.)”) followed by any single character, then the same first
character, followed by any single character, and then the same first
character again. For example, it will match “a.a.a” or “1.1.1”.
“(.)(.)(.).\3\2\1”: This expression will match any three characters
(represented by “(.)(.)(.)”) followed by zero or more of any characters
(represented by “.”) and then the third character, followed by the
second character, and then the first character. For example, it will
match “abcabczycba” or “xyzzzzzyx”.
#4 Construct regular expressions to match words that: # Start and end
with the same character.
)
Contain a repeated pair of letters (e.g. “church” contains “ch”
repeated twice.)
()\1
Contain one letter repeated in at least three places (e.g. “eleven”
contains three “e”s.)
()\1\1