This function replaces the text matched by the last search with replacement.
This function replaces the text in the buffer (or in string) that was matched by the last search. It replaces that text with replacement.
If you did the last search in a buffer, you should specify
nilfor string. Thenreplace-matchdoes the replacement by editing the buffer; it leaves point at the end of the replacement text, and returnst.If you did the search in a string, pass the same string as string. Then
replace-matchdoes the replacement by constructing and returning a new string.If the fourth argument string is a string, fifth argument strbuffer specifies the buffer to be used for syntax-table and case-table lookup and defaults to the current buffer. When string is not a string, the buffer that the match occurred in has automatically been remembered and you do not need to specify it.
If fixedcase is non-
nil, then the case of the replacement text is not changed; otherwise, the replacement text is converted to a different case depending upon the capitalization of the text to be replaced. If the original text is all upper case, the replacement text is converted to upper case. If the first word of the original text is capitalized, then the first word of the replacement text is capitalized. If the original text contains just one word, and that word is a capital letter,replace-matchconsiders this a capitalized first word rather than all upper case.If
case-replaceisnil, then case conversion is not done, regardless of the value of fixedcase. See Searching and Case.If literal is non-
nil, then replacement is inserted exactly as it is, the only alterations being case changes as needed. If it isnil(the default), then the character ‘\’ is treated specially. If a ‘\’ appears in replacement, then it must be part of one of the following sequences: