var wordsString="car/home/pencil,Joe/Hugh/Jack/Chris";
var word='home';
var pattern1=/^/+word;
var pattern2=/,/+word;
var pattern3 =/\//+word;
var matched = wordsString.match(pattern1+ /|/ +pattern2+ /|/ + pattern3 + /g/);
I want to match results from wordsString by using pattern1, pattern2, pattern3.
I need to match according to pattern1 or pattern2 or pattern3. But I get null.
Where is the problem?
/home/? is it that you want to use a variable to make the regexp?