Exercise 1

stat_or_data_majors = str_view(majors$Major, "STATISTICS|DATA")
print(stat_or_data_majors)
## [44] │ MANAGEMENT INFORMATION SYSTEMS AND <STATISTICS>
## [52] │ COMPUTER PROGRAMMING AND <DATA> PROCESSING
## [59] │ <STATISTICS> AND DECISION SCIENCE

Exercise 2

strIn =
'[1] "bell pepper"  "bilberry"     "blackberry"   "blood orange"
[5] "blueberry"    "cantaloupe"   "chili pepper" "cloudberry"  
[9] "elderberry"   "lime"         "lychee"       "mulberry"    
[13] "olive"        "salal berry"'




strIn = str_remove_all(strIn, "\\[[0-9]+\\]")
strIn = str_remove_all(strIn, "\\n")
strIn = str_replace_all(strIn, '"\\s+"', '", "')
strIn = str_replace_all(strIn, '^\\s', 'c(')
strIn = str_replace_all(strIn, '$', ')')

message(strIn)
## c("bell pepper", "bilberry", "blackberry", "blood orange", "blueberry", "cantaloupe", "chili pepper", "cloudberry", "elderberry", "lime", "lychee", "mulberry", "olive", "salal berry")

Exercise 3

Part A

(.)\1\1 : This will match a character that is followed by \1\1 such as z\1\1 or bro\1\1.

partA = c("n\1\1", "man\1\1", "free\1\1", "50123")

partA = str_view(partA, "(.)\1\1")

message(partA)
## <n>ma<n>fre<e>

Part B

(.)(.)\2\1 : This will match two characters or numbers that repeat themselves in a reverse order for example lool, roor .

partB = c("kahoot","lool", "foof", "boot", "manolo", "manlbblnam","goodwin", "154451")

partB = str_view(partB, "(.)(.)\\2\\1")

message(partB)
## <lool><foof>man<lbbl>nam1<5445>1

Part C

(..)\1 : This expression will match with any 2 character followed by \1 for example hi\1 and going\1man .

partC = c("boot\1", "search\1check", "o\1", "23\15", "going\1man")
partC = str_view(partC, "(..)\1")
message(partC)
## bo<ot>sear<ch>checkgoi<ng>man

Part D

(.).\1.\1 : This expression will match with a character or number by skipping one character two times and repeating it after eack skip for example popopa or 50505 .

partD = c("bobob", "10101", "bob", "oddodo", "10232j2")
partD = str_view(partD, "(.).\\1.\\1")
message(partD)
## <bobob><10101>10<232j2>

Part E

(.)(.)(.).*\3\2\1 : This expresion matches up to three characters that reapeat themselves in reverse order and it may or may not have any set of characters between the three character groups for example orbppppbro,ban234802nab or arttra .

partE = c("", "orbppppbro","pro787877horp","vocadkvjdlsaov","chmughagumch", "amoreeeeroma" , "arttra", "to39843ot", "abreatha", "am432432ma")
partE = str_view(partE, "(.)(.)(.).*\\3\\2\\1")
message(partE)
## <orbppppbro><pro787877horp>ch<mughagum>ch<amoreeeeroma><arttra><to39843ot>

Exercise 4

part A

^(.).*\1$

part4A = c("map", "yossdflky", "bob", "mathewms")
part4A = str_view(part4A, "^(.).*\\1$")
message(part4A)
## <yossdflky><bob>

part B

(..).*\1

part4B = c("church", "bobo", "platolap", "mathewms")
part4B = str_view(part4B, "(..).*\\1")
message(part4B)
## <church><bobo>p<latola>p

part C

(.).\1.\1

part4C = c("eveven", "manolofo", "great evening", "romodo")
part4C = str_view(part4C, "(.).*\\1.*\\1")
message(part4C)
## <eveve>nman<olofo>gr<eat eve>ningr<omodo>