I’m passing a string to a function and that string is not a regexp. Inside that function, I’m calling another function which takes a regexp.
The problem I’m having is that I’m passing, say:
"i.."
which does not represent a regexp and I’d then like to “convert” it to a regexp that shall match that exact string.
For example, I take it converting my non-regexp “i..” to:
"i[.][.]"
would work in my case because then that regexp would match “i..”.
I’m looking for something that would work with most characters but it’s not a big deal if I cannot use ‘[‘ and ‘]’ in my input string.
So how can I programmatically “wrap” my non-regexp string into a regexp automatically so that that regexp matches my exact (non-regexp) string?
you are looking for the
regexp-quotefunction.