When reading the description of “replace-match” function in Emacs I can’t understand what is the ‘subexpression’ attribute and how it should be used? For example in
(replace-match (format-time-string writestamp-format (current-time)) t t nil 1)
what does the ‘1’ mean?!
When reading the description of replace-match function in Emacs I can’t understand what is
Share
From the manual:
You will need to understand subexpressions of a regular expression first, to understand this feature: By delimiting a part of a regular expression with braces, you can group it and then access those groups. This is very useful if you want to reuse parts of the match in the replacement text when doing a
query-replace-regex. This is simply the way it works here.Imagine you want to replace every occurence of
bar(SOMETHING)withfoo(SOMETHING). So you first match withbar(\([^)]*\))(this means every character besides)is allowed within the parentheses and that our first subexpression is everything that is matched between\(and\).