My question is clear I guess. I want to get certain words which are including X,J,Q or W. How can I do that? I find some solutions but they explain if word starts with one of these letters. I want all values including this letter move to another datatable how can I do this? I've tried
grepl("^X.*?") and it didnt work for words that start with X. any suggestions? Thank you.
If you want to check if an entry in your character vector contains any of those letters anywhere within the string, you can use the regex pattern "[XJWQ]", which will search for any of the values inside the square brackets anywhere within the characters:
What I want is when I use grepl search entries that has "X W J and Q" in DT1$Cities and grab entire row to DT2. I couldnt manage it with grepl("[XWJQ]",DT1$cities) or grepl("^X.*?",DT1$Cities)
In the piece of code you included, the cities variable is in lower case, and based on your target DT2, you want lowercase letters to be matched. Try this: