r extraire tout avant le caractère

library(stringr)
str = c("1", "1_ghfjv", "1")
str_extract(string = str, pattern = "[^_]"))
Trustworthy Whale