How to properly create regex from string in Javascript? : <p>I'm struggle with an issue and don't understand why is this happen. I have an regex, which store in DB and for validation it's taken from server.</p>

<p>But on client side when I'm trying to transform my regex from string using <code>new RegExp()</code> I'm struggle with a problem.</p>

<p>My code <code>new RegExp('\d');</code> returns <code>/d/</code>, but should <code>/\d/</code>, is anybody can help me with this? Where I miss the things?</p>

<p>I was looked this answer <a href="https://stackoverflow.com/questions/6521572/javascript-regex-not-working">Javascript RegEx Not Working</a> but I don't think that my issue is duplicate of existing one. Because of here is explained how to convert to regex from string, but in my issue new regExp eat '\' symbol and I'm not understand why and what should to do to avoid this?</p>
