I am trying to write a regexp to mean:

At least one of a few punctuation marks followed by any number of blank spaces followed by a literal star is to be replaced by all those punctuation marks followed by a literal star.

So, when doing interactively,

\([.,?!:;]+\)[[:blank:]]*\* is replaced by \1*

But in elisp, I am not able to get the literal star. I tried:

\\(\[\.,;:?।\]\+\\)\[\[:blank:\]\]\*\\* to be replaced by \\1\\*

But it does not work.

Will you please point what is wrong? I think I am not escaping the literal star correctly. But I am not able to see what is the correct method.

1 Answer 1


The correct string is "\\([.,?!:;]+\\)[[:blank:]]*\\*".

Here's trick: evaluate (read-string "regexp: "), enter your regexp, and look at the result.

If you use Helm, helm-regexp is a great tool for exploring regexps, then converting them to strings via the Kill regexp as sexp action.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.