Hello I have a string as a linux command like this
x <- "cd/etc/init[BKSP][BKSP]it.d[ENTER]"
I want to split the string by character and keep the content inside of the square bracket intact. Basically I want to retain the command press. The result would look some thing like this if using str_split
:
c("c","d","/","e","t","c","i",......"BKSP","BKSP","i","t",".", "d", "ENTER")
Can someone help me with this problem? I've been playing with regex and haven't figured out how to achieve this.
I tried /.*?[^[A-Z*?]/
but I didn’t do the trick. I’m also trying to add the delimiter to the matching group to split the string, too.