I am trying to split a string using ‘split-string’ function based on the . character. But
(split-string "1.2.3" ".") doesn’t work at all. It just returns a list of variable number of empty strings. Is . a special character that needs to be escaped or specified in some different way?
I am trying to split a string using ‘split-string’ function based on the .
Share
Here is the official documentation for split-string function –
https://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Strings.html
The second argument to the split-string function in
(split-string "1.2.3" "\.")is a regular expression and as a result both the ‘.’ character and ” character have special meaning. So the ‘.’ character needs to be escaped and even the ” character needs to be escaped with another ”.(split-string "1.2.3" "\\.")will work fine as expected.