I frequently need to split strings, while keeping the
separator. Researching the elisp manual, I am not finding a way to split a string according to a separator, without consuming the separator itself.
split-string splits a given string into substrings based on the regular expression separators, but the substrings lose the separator:
(split-string "* one * two * three" "\*")
("" " one " " two " " three")
I could use
s-slice-at, from @magnars s.el
(s-slice-at "\*" "* one * two * three")
("* one " "* two " "* three")
I could also try to rewrite
split-string myself. Still, I was wondering if there is a built-in way to do it as part of Emacs core?
If not, could somebody please point to a good way to do that properly?