I'm trying to remove square brackets that don't have spaces between them, but keep square brackets that do. For example:
The new version of
stringr may be of use to you, it has a nice widget for testing out
stringr::str_view_all(c("[please]", "[help me]"), "(\\[)\\S*(\\])")
[, then any number of non-space characters, then
], with the
] as capture groups. I'm not sure what you want to do with them.
Update: To remove brackets, you actually want to capture what's inside and then substitute with it.
stringr::str_replace_all(c("[please]", "[help me]"), "\\[(\\S*)\\]", "\\1") #>  "please" "[help me]"
(capture any all-non-space characters between brackets, and substitute the entire string for the capture where found)