# Example data strings <- c( "thymosin beta 10 [Source:HGNC Symbol;Acc:HGNC:11879]", "example [Some:Text]", "another string [More:Info]" ) # Remove text between square brackets cleaned_strings <- gsub("\\s*\\[.*?\\]", "", strings) # Print the cleaned strings print(cleaned_strings)