x <- "my string is sad" sub(" .*", "", x) sub("[[:space:]].*", "", x) sub("(*UCP)(?s)\\s.*", "", x, perl=TRUE) # PCRE Unicode-aware regex ## stringr::str_replace(x, "(?s) .*", "") # (?s) will force . to match any chars