I am aware that in grep you can simply use ignore.case = TRUE
. However, what about strsplit? You can pass a regular expression as the second argument, but I'm not sure how I make this regular expression case insensitive.
Currently, this is what my strsplit looks like, but I want to make the search case insensitive. How would I do so?
strsplit(df$sentence, paste0(" ", df$node, "( |[!\",.:;?})\\]])"))
Example:
sentence <- "De A-bom, Sint...";
node <- "a-bom"
contexts <- strsplit(sentence, paste0("(?i) ", node, "( |[!\",.:;?})\\]])"))
(leftContext <- sapply(contexts, `[`, 1))
Expected return:
[1] "De"
Actual return:
[1] "De A-bom, Sint..."
Note, however that the regex itself does work online.