1. [代码]javascript 简单的search
<script(?:(?:\s|.)+?)src=[\"\‘](.+?)[\"\‘](?!\<)(?:(?:\s|.)*?)(?:(?:\/\>)|(?:\>\s*?\<\/script\>))
<script src="sdfsdf/sdfd.js"
type="text/javascript" />
<script
type="text/javascript" src="sdfsdf/sdfd.js">
</script>
<script type="text/javascript" src="sdfsdf/sdfd.js">
</script>
<script type="text/javascript"
src="sdfsdf/sdfd.js"
/>
<script type="text/javascript"
src="sdfsdf/sdfd.js"
>
</script>
?2. [代码][JavaScript]代码
var fs=require(‘fs‘);
var path=require(‘path‘);
function quick_cloud(page_path){
var content=fs.readFileSync(page_path);
//正则标识符g 表示:reg.exec 会扫描到content最后一个匹配项,直到返回null
var link_reg=/<link(?:.*?)href=[\"\‘](.+?)[\"\‘](?!<)(?:.*)\>(?:[\n\r\s]*?)(?:<\/link>)*/gm;
var js_reg=/<script(?:.*?)src=[\"\‘](.+?)[\"\‘](?!<)(?:.*)\>(?:[\n\r\s]*?)(?:<\/script>)*/gm;
var img_reg=/<img(?:.*?[\n\r\s]*.*?)src=[\‘\"](.+?)[\‘\"](?!<)(?:.*?[\n\r\s]*.*?)\/*>/gm;
var link_search_arr=[];
var js_search_arr=[];
var img_search_arr=[];
while(match_link=link_reg.exec(content)){
var obj={match:match_link[0],group:match_link[1]};
link_search_arr.push(obj);
};
console.log(link_search_arr);
while(match_js=js_reg.exec(content)){
var obj={match:match_js[0],group:match_js[1]};
js_search_arr.push(obj);
}
console.log(js_search_arr);
while(match_img=img_reg.exec(content)){
var obj={match:match_img[0],group:match_img[1]};
img_search_arr.push(obj); flash
}http://www.huiyi8.com/donghua/?
console.log(img_search_arr);
var pagedir=path.dirname(page_path);
link_search_arr.forEach(function(res_obj,index){
console.log(resolve_res_path(pagedir,res_obj.group));
});
}
?3. [代码]style简单的search
<link(?:(?:\s|.)+?)href=[\"\‘](.+?)[\"\‘](?!\<)(?:(?:\s|.)*?)(?:(?:\/\>)|(?:\>\s*?\<\/link\>))
<link href="sdfsdf/sdfd.css"
type="text/css" />
<link href="sdfsdf/sdfd.css"
type="text/css"
/>
<link href="sdfsdf/sdfd.css"
type="text/css"
></link>
<link href="sdfsdf/sdfd.css"
type="text/css"
>
</link>
<link href="sdfsdf/sdfd.css"
>
</link>
<link href="sdfsdf/sdfd.css"/>
<link href="sdfsdf/sdfd.css"></link>
?