RegExp not doing as expected
Solved, needs double slashes. Couldn't find this documented very well!!
by Terry King
HTML
<p>Would expect two matches:</p>
<div id="results1"></div>
<p>This one should work!:</p>
<div id="results2"></div>
JavaScript
s='This is a comment from my iPhone!<p style="font-size:9px;">Edited Fri Oct 25 2013 10:35:39 GMT+0100 (GMT Daylight Time)</p> "';
reg=new RegExp('([\s\S]*)(<p.+Edited.+</p>)','');
matches=s.match(reg);
for(i in matches){
$("#results1").append(i+">"+matches[i]+'<br>');
}
reg=new RegExp('([\\s\\S]*)(<p.+Edited.+</p>)','');
matches=s.match(reg);
for(i in matches){
$("#results2").append(i+">"+matches[i]+'<br>');
}