multiple regex match using javascript
<pre><code>var wordsString=&quot;car/home/pencil,Joe/Hugh/Jack/Chris&quot;;
var word='home';
var pattern1=/^/+word;
var pattern2=/,/+word;
var pattern3 =/\//+word;

var matched = wordsString.match(pattern1+ /|/ +pattern2+ /|/ + pattern3 + /g/);
</code></pre>
<p>I want to match results from <code>wordsString</code> by using <code>pattern1</code>, <code>pattern2</code>, <code>pattern3</code>.</p>
<p>I need to match according to <code>pattern1</code> or <code>pattern2</code> or <code>pattern3</code>. But I get <code>null</code>.</p>
<p>Where is the problem?</p>