title: Javascript Regexp dynamic generation from variables?
body: <p>How to construct two regex patterns into one?</p>
  
  <p>For example I have one long pattern and one smaller, I need to put smaller one in front of long one.</p>
  
  <pre><code>var pattern1 = ':\(|:=\(|:-\(';
  var pattern2 = ':\(|:=\(|:-\(|:\(|:=\(|:-\('
  str.match('/'+pattern1+'|'+pattern2+'/gi');
  </code></pre>
  
  <p>This doesn't work. When I'm concatenating strings, all slashes are gone.</p>