gsub with “|” character in R
问题 I have a data frame with strings under a variable with the | character. What I want is to remove anything downstream of the | character. For example, considering the string heat-shock protein hsp70, putative | location=Ld28_v01s1:1091329-1093293(-) | length=654 | sequence_SO=chromosome | SO=protein_coding I wish to have only: heat-shock protein hsp70, putative Do I need any escape character for the | character? If I do: a <- c("foo_5", "bar_7") gsub("*_.", "", a) I get: [1] "foo" "bar" i.e. I