Hello,
I'm new to lisp and am trying to customize Emacs. I'd like the ability to
pass a string to a function and do a search-and-replace on that string.
All the built-in Emacs lisp functions I can find (e.g. replace-string,
replace-match), perform a search-and-replace on the last text searched for
in the text buffer, rather than a string I pass. Is there a lisp function
that can do a search-and-replace on a string I pass, or do I have to build
my own?
Any assistance provided is much appreciated!
Thanks,
Ethan
In article <············@news1.gtech.com>,
Ethan C. Eldridge <··············@gtech.com> wrote:
>I'm new to lisp and am trying to customize Emacs. I'd like the ability to
>pass a string to a function and do a search-and-replace on that string.
Emacs Lisp questions are best asked in the Emacs newsgroups, either
comp.emacs or gnu.emacs.help.
>All the built-in Emacs lisp functions I can find (e.g. replace-string,
>replace-match), perform a search-and-replace on the last text searched for
>in the text buffer, rather than a string I pass. Is there a lisp function
>that can do a search-and-replace on a string I pass, or do I have to build
>my own?
string-match will search for a regexp in a string you supply. You can then
use match-beginning and match-end to get the indices of the start and end
of the match, and use substring and concat to build a new string based on
that.
--
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.