elisp regexp search in strings, not buffers

Here is a discussion of string content vs buffer content in the Emacs wiki. Just store your string as a variable.

The tricky thing about strings is that you generally do not modify the string itself (except if you perform array functions on string, since a string is an array, but this should generally be avoided), but you return the modified string.

At any rate, here is an example of using a string in elisp.

This will trim the whitespace from the end of a string:

(setq test-str "abcdefg  ")
(when (string-match "[ \t]*$" test-str)
    (message (concat "[" (replace-match "" nil nil test-str) "]")))

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)