Hello I have a string such as
string="some containt[OKUUUDN?DD];some other contaian[HDJD.HHD]"
how can I remove part between [ and ]?
I tried :
gsub("[&]", "", string)
I should get :
"some containt;some other contaian"
Hello I have a string such as
string="some containt[OKUUUDN?DD];some other contaian[HDJD.HHD]"
how can I remove part between [ and ]?
I tried :
gsub("[&]", "", string)
I should get :
"some containt;some other contaian"
You can use \\[.*?] to remove everything between [ and ]. [ needs to be escaped \\[, . means everything, * means repeated 0 to n, ? means non greedy to remove not everything from the first to the last match.
gsub("\\[.*?]", "", string)
#[1] "some containt;some other contaian"