library(tidyverse)
library(here)
data = read.csv(here('majors-list.csv'))
data |> select('Major') |> filter(str_detect(Major, 'DATA|STATISTICS'))
## Major
## 1 MANAGEMENT INFORMATION SYSTEMS AND STATISTICS
## 2 COMPUTER PROGRAMMING AND DATA PROCESSING
## 3 STATISTICS AND DECISION SCIENCE
Data: [1] “bell pepper” “bilberry” “blackberry” “blood orange” [5] “blueberry” “cantaloupe” “chili pepper” “cloudberry” [9] “elderberry” “lime” “lychee” “mulberry” [13] “olive” “salal berry”
list = c("bell pepper", "bilberry", "blackberry", "blood orange","blueberry", "cantaloupe", "chili pepper", "cloudberry","elderberry", "lime", "lychee", "mulberry","olive", "salal berry")
list
## [1] "bell pepper" "bilberry" "blackberry" "blood orange" "blueberry"
## [6] "cantaloupe" "chili pepper" "cloudberry" "elderberry" "lime"
## [11] "lychee" "mulberry" "olive" "salal berry"
(.)\1\1 => This regular expression identifies sequences of three consecutive identical characters.`
str_detect(c( "AAA", "999","99"),"(.)\\1\\1")
## [1] TRUE TRUE FALSE
(.)(.)\2\1 => This regular expression detects strings consisting of four characters, where the first and last characters are identical, while the two middle characters are also identical but distinct from the first and last.
str_detect(c("noon","1212","xyyx"),'(.)(.)\\2\\1')
## [1] TRUE FALSE TRUE
(..)\1 => This regular expression pinpoints strings of at least four characters, where the initial two characters are equivalent to the subsequent two characters.`
str_detect(c('noon',"1212","xyyx"),'(..)\1')
## [1] FALSE FALSE FALSE
(.).\1.\1 => This regular expression recognizes strings comprising five characters, where the first character matches the third and fifth characters, and the second character differs.`
str_detect(c("AXA","121","bYb"),'(.).\\1.\\1')
## [1] FALSE FALSE FALSE
**(.)(.)(.).*\3\2\1 =>** This regular expression identifies strings of at least six characters, where the first three characters form a palindrome.`
str_detect(c("121AABBA", "xyx12345zyx","wow987654321"),'(.)(.)(.).*\\3\\2\\1')
## [1] FALSE FALSE FALSE
Start and end with the same character.
str_detect('tarot','^(.).*\\1$')
## [1] TRUE
Contain a repeated pair of letters.
str_detect("church",".*(.{2}).*\\1.*")
## [1] TRUE
Contain one letter repeated in at least three places (e.g. “eleven” contains three “e”s.)
str_detect("eleven","([a-z]).*\\1.*\\1")
## [1] TRUE