I need to convert string like \"/[\\w\\s]+/\" to regular expression.
\"/[\\w\\s]+/\" => /[\\w\\s]+/
I tried using different Regexp
This method will safely escape all characters with special meaning:
/#{Regexp.quote(your_string)}/
For example, . will be escaped, since it's otherwise interpreted as 'any character'.
Remember to use a single-quoted string unless you want regular string interpolation to kick in, where backslash has a special meaning.