for example if we consider document.createElement() function the parameter can be passed in 3 ways
var v="script";
var s=document.createElement(v);
var s=document.createElement("script");
var s=document.createElement('scipt');
i want a regular expression which extracts the parameter in document.createElement function excluding quotes. I tried this by using groups but i am writing two regular expression one for "",'' and other for normal variable please provide an example
var f = document.createElement; document.createElement = function(tagName){ console.log(tagName); f.apply(document, arguments); }
This code is tracking document.createElement
calls dynamically, though. I.e. One cannot say about some code which tags are created beforehead - kirilloid 2012-04-04 08:18
var re = /document\.createElement\((['"]*)(.+?)\1\)/;
The result is in:
str.match(re)[2];
http://jsfiddle.net/mihaifm/RWc8N/
Use pipe - |
for OR operations.
For example: script|scipt
.
document.createElement
to make hook. Also, script may be inserted viadocument.body.innerHTML += "<script type='text/javascript'></script>"
- kirilloid 2012-04-04 07:37