extract everything before space r code example
Example 1: r extract everything before character
library(stringr)
str = c("1", "1_ghfjv", "1")
str_extract(string = str, pattern = "[^_]"))
Example 2: extract word until the first space R
gsub("(.+?)(\\_.*)", "\\1", "L0_123_abc")