.exec() with regex strange results

3 views
Skip to first unread message

Samuel Deering

unread,
Aug 11, 2011, 2:47:17 AM8/11/11
to We love jQuery
Paste this code into Firebug! http://jsfiddle.net/THdtm/


/* match just the href of js includes */
var jsSrcRegex = /src=\"(.+?)\"/igm;

/* html for js include */
var html = '<script type="text/javascript" src="/
jquery-1.4.2.min.js"></script>';

console.dir(jsSrcRegex.exec(html));

console.log(html);
console.log(jsSrcRegex);

console.dir(jsSrcRegex.exec(html));

/*

No results? wtf?

Then wait!!!

add an extra console.log! and...
*/

console.dir(jsSrcRegex.exec(html));

/* results are back!! hmm... */
Reply all
Reply to author
Forward
0 new messages