On Thu, May 23, 2019 at 11:46:29AM +0700, Budi wrote: > (setq ntimes 7) > re-search-forward "hello\\{ntimes\\}" > > How is above supposed to work ? It's not supposed to work ;-) (the specific construct above takes a constant between \{ and \}). Usually you construct your string using whatever other facilities Elisp has, e.g. (let* ((ntimes 17) (re (format "fo\\{%d\\}" ntimes))) (re-search-forward re)) ; searches for 'f' followed by 17 'o's Be extra careful for variables containing regular expression special characters (in the above case of an int, there is no danger). Use the function 'regexp-quote' as needed. If you are doing more complex things, you might like 'rx', which allows you to write regular expressions in S-expression syntax, thus giving you access to template macros and all that goodness. Cheers -- t