Rumah  >  Artikel  >  hujung hadapan web  >  论坛转贴工具中用到的正则表达式学习正则的好例子_javascript技巧

论坛转贴工具中用到的正则表达式学习正则的好例子_javascript技巧

WBOY
WBOYasal
2016-05-16 19:08:161150semak imbas

电脑教程吧-常用论坛转贴工具

\n"); str = str.replace(/]*?D27CDB6E\-AE6D\-11cf\-96B8\-444553540000[^>]*?>.*]+name\s*=\s*["](url|src)["][^>]+value=[" ]?([^"]+)[" ][^>]*>.*/ig,"\n
Flash动画
\n"); str = str.replace(/]*type=["]?application\/x\-shockwave\-flash["]?[^>]*src=[" ]?([^"|^ ]+)[" ]?[^>]*>/ig,"\n
Flash动画
\n"); str = str.replace(/]*src=["]?([^"|^ ]+)["]?[^>]*type=["]?application\/x\-shockwave\-flash["]?[^>]*>/ig,"\n
Flash动画
\n"); str = str.replace(/]*?CFCDAA03\-8BE4\-11cf\-B84B\-0020AFBBCCFA[^>]*?>.*]+name\s*=\s*["](url|src)["][^>]+value=[" ]?([^"]+)[" ][^>]*>.*/ig,"\n
播放real视频流文件
\n"); } if(!set.font_b.checked&&!set.stext.checked){ str = str.replace(//ig,"[$1b]"); str = str.replace(//ig,"[$1b]");} if(!set.font_u.checked&&!set.stext.checked) str = str.replace(//ig,"[$1u]"); if(!set.font_i.checked&&!set.stext.checked) str = str.replace(//ig,"[$1i]"); str = str.replace(/ /g," "); str = str.replace(/&/g,"&"); str = str.replace(/"/g,"\""); str = str.replace(/,"/g,">"); } str = str.replace(/ /ig,"\n"); str = str.replace(/

]*?>/ig,"\n\n"); str = str.replace(/]*?>/g,""); str = str.replace(/\[url=([^\]]+)\]\n(\[img\]\1\[\/img\])\n\[\/url\]/g,"$2"); str = str.replace(/\n+/g,"\n"); return str; } function copycode(obj){ obj.select(); objcopy=obj.createTextRange(); objcopy.execCommand("Copy"); } function trans(){ var str = ""; rtf.focus(); rtf.document.body.innerHTML = ""; rtf.document.execCommand("paste"); str = rtf.document.body.innerHTML; if(str.length == 0) { alert("剪贴版不存在超文本数据!"); return ""; } return html_trans(str); } function preview(){ var prewin=window.open("","",""); prewin.document.write(rtf.document.body.innerHTML); } function zhen(str) { strfound=str.replace(/\\/ig,"\\\\"); strfound=strfound.replace(/\[/ig,"\\["); strfound=strfound.replace(/\]/ig,"\\]"); strfound=strfound.replace(/\{/ig,"\\{"); strfound=strfound.replace(/\}/ig,"\\}"); strfound=strfound.replace(/\|/ig,"\\|"); strfound=strfound.replace(/\//ig,"\\/"); strfound=strfound.replace(/\^/ig,"\\^"); strfound=strfound.replace(/\./ig,"\\."); strfound=strfound.replace(/\*/ig,"\\*"); strfound=strfound.replace(/\?/ig,"\\?"); strfound=strfound.replace(/\+/ig,"\\+"); return strfound; } function replace_star() { var str=document.getElementById('text').value; if(!reg.checked) strfound=zhen(find_text.value); else strfound=find_text.value; var re = new RegExp(strfound,"ig"); str=str.replace(re,replace_text.value); document.getElementById('text').value=str; }

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn