当前位置:首页 > 通信资讯 > 正文

WebRegExp 1.0 - 客服果果 [ 无忧版 ]对于想学习正则的朋友是个不错的在线工具,测试你正则的正确性。

  1. <!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <htmlxmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
  5. <title>WebRegExp1.0-客服果果[无忧版]</title><basehref="http://www.dhooo.com/web/"/>
  6. <styletype="text/css">
  7. body{background:#2B3C53;}*{font-size:12px;}#win{width:900px;font-size:12px;position:absolute;left:0;top:0;background:#F1F0EA;border:2pxoutset;color:#000;-moz-border-top-colors:#d4d0c8white;-moz-border-left-colors:#d4d0c8white;-moz-border-right-colors:#404040#808080;-moz-border-bottom-colors:#404040#808080;}h4{background:#35528Eurl(images/caption.jpg)repeat-y100%0;margin:1px;padding:5px;cursor:default;color:#fff;font-size:14px;font-family:Arial;}h4div{background:url(images/ico.gif)no-repeat2px0;padding-left:25px;}#about{text-decoration:none;color:#000;padding:2px}.menu{line-height:20px;padding:0px10px}.line{font-size:1px;line-height:1px;background:#fff;margin:02px;height:1px;overflow:hidden;border-top:1pxsolid#ACA899;}.ad{background:#FF7B00url(images/regexp_ad.gif)no-repeat50%50%;height:60px;position:relative;}.ibody{margin:5px;}.left{width:250px;height:100%;float:left;text-align:center;}.btnWrap{padding:5px0;}button{+margin-left:2px;padding:0px;}#tabBtnsa{color:#000;text-decoration:none;display:block;float:left;margin-right:1px;width:47px;height:20px;line-height:20px;background:#fffurl(images/tab.gif)no-repeat00;}.list_wrap{margin:5px;}#tabBtns{z-index:10;border:0pxsolid#aaa;}#tabBtnsa:hover{background:url(images/tab.gif)no-repeat0-21px;}#tabBtnsa.hot,#tabBtnsa.hot:hover{background:url(images/tab.gif)no-repeat0100%;width:52px;height:20px;position:relative;bottom:-1px;}.list_option{background:#fff;margin:0px;padding:0px;border:1pxsolid#919B9C;display:none;}#list_match.list_option{display:block;}.right{width:636px;float:right;}.clear{clear:both;font-size:0px;overflow:hidden;height:0px;}#colorText,textarea{margin:5pxauto;height:100px;overflow:auto;border:1pxsolidinset;}#colorText{background:#fff;text-align:left;word-wrap:break-word;overflow:hidden;}#regexpText{width:236px}#replaceText{height:30px;}#regexpText{height:60px;}#replaceText,#targetText,#resultText{width:620px}#targetText{height:200px;background:#ddd;color:#000;}#resultText{height:60px;color:#0099FF}select{width:216px;height:170px;margin:0px;padding:0px;margin-top:10px;}fieldset{text-align:center;padding:0;margin:10px000}legend{margin-left:10px;color:#000;}
  8. </style>
  9. </head>
  10. <body>
  11. <divid="win">
  12. <h4>
  13. <divid="caption">
  14. WebRegExp1.0-客服果果[无忧版]
  15. </div>
  16. </h4>
  17. <divclass="menu">
  18. <ahref="javascript:void(0)"id="about"onclick="alert('感谢使用WebRegExp1.0')">关于(<u>A</u>)</a>
  19. </div>
  20. <divclass="line">
  21. </div>
  22. <divclass="ad">
  23. </div>
  24. <divclass="ibody">
  25. <divclass="left">
  26. <fieldset>
  27. <legend>正则式输入</legend><textareaid="regexpText"><[^>]+></textarea>
  28. <divclass="btnWrap">
  29. <buttonid="doOut">输出</button><buttonid="doTrim">剔除</button><buttonid="doReplace">替换</button><buttonid="doNext">查找下一个</button><buttonid="doFind">列表</button>
  30. </div>
  31. </fieldset>
  32. <fieldset>
  33. <legend>模式匹配</legend><labelfor="isI"><inputtype="checkbox"id="isI"m="i"/>忽略大小写</label><labelfor="isM"><inputtype="checkbox"id="isM"m="m"/>多行模式</label><labelfor="isG"><inputtype="checkbox"id="isG"m="g"checked/>全局模式</label>
  34. </fieldset>
  35. <fieldsetclass="">
  36. <legend>常用正则式</legend>
  37. <divclass="list_wrap">
  38. <divid="tabBtns">
  39. <ahref="javascript:void(0)"title="">验证</a><ahref="javascript:void(0)"title=""class="hot">提取</a><ahref="javascript:void(0)"title="">剔除</a>
  40. <divclass="clear">
  41. </div>
  42. </div>
  43. <divid="all_list">
  44. <divclass="list_option"id="list_check">
  45. <selectid="exps1"size="2">
  46. </select>
  47. </div>
  48. <divclass="list_option"id="list_match">
  49. <selectid="exps2"size="2">
  50. </select>
  51. </div>
  52. <divclass="list_option"id="list_trim">
  53. <selectid="exps3"size="2">
  54. </select>
  55. </div>
  56. </div>
  57. </div>
  58. </fieldset>
  59. </div>
  60. <divclass="right">
  61. <fieldset>
  62. <legend>测试文本</legend><textareaid="targetText"><!--testText-->
  63. <tablecellspacing="0"cellpadding="4"width="100%"align="center"class="t_row">
  64. <trstyle="height:100%">
  65. <tdwidth="18%"valign="top"class="t_user">
  66. <aname="pid575004"></a><aname="newpost"></a><ahref="space.php?uid=94039"target="_blank"class="bold">客服果果</a>
  67. <divclass="smalltxt">
  68. 爬虫<imgsrc="images/default/star_level2.gif"alt="Rank:2"/>
  69. <tablewidth="95%"border="0"cellspacing="0"cellpadding="0"style="table-layout:fixed;overflow:hidden">
  70. <tr>
  71. <tdalign="center">
  72. <divclass="avatar"style="width:70">
  73. <imgsrc="images/avatars/16.gif"width="70"height="80"border="0"alt=""/>
  74. </div>
  75. </td>
  76. </tr>
  77. </table>
  78. <!--testTextend--></textarea>
  79. </fieldset>
  80. <fieldset>
  81. <legend>替换文本</legend><textareaid="replaceText">dhooo</textarea>
  82. </fieldset>
  83. <fieldset>
  84. <legendid="reInfo">查找结果</legend><textareaid="resultText"></textarea>
  85. </fieldset>
  86. </div>
  87. <divclass="clear">
  88. </div>
  89. </div>
  90. </div>
  91. <script>ldh={ex:function(main,ex){for(varkin(ex||{}))main[k]=ex[k];returnmain},each:function(list,fn){for(vari=0;i<list.length;i++)fn.call(list[i],i,list)},chk:function$chk(obj){return!!(obj||obj===0)},find:function(selector,box){if(typeof(selector)!='string')returnselector;if(selector.charAt(0)=='.')return(function(className,box){varlist=[];ldh.each(ldh.find('*',box),function(i){if(this.className.indexOf(className)!=-1)list.push(this)})returnlist;})(selector.replace('.',''),ldh.find(box));if(selector.charAt(0)=='#')returndocument.getElementById(selector.replace('#',''));return(ldh.find(box)||document).getElementsByTagName(selector);}};ldh.ex(ldh,{drag:function(hander,ini){ini=ldh.ex({win:false,dir:'xy'},ini);varmover=ini.win||hander;mover.style.position="absolute";hander.onmousedown=function(e){e=window.event||e;this.x=e.clientX-mover.offsetLeft;this.y=e.clientY-mover.offsetTop;if(document.all){hander.onlosecapture=dragStop;hander.setCapture();}else{window.onblur=dragStop;}document.onmousemove=function(e){e=window.event||e;varx=e.clientX-hander.x,y=e.clientY-hander.y;ldh.chk(ini.left)&&(x=Math.max(x,ini.left));ldh.chk(ini.top)&&(y=Math.max(y,ini.top));ldh.chk(ini.right)&&(x=Math.min(x,ini.right));ldh.chk(ini.bottom)&&(y=Math.min(y,ini.bottom));if(ini.dir.indexOf('x')!=-1)mover.style.left=x+"px";if(ini.dir.indexOf('y')!=-1)mover.style.top=y+"px";if(document.all){hander.setCapture();e.cancelBubble=true;}else{e.preventDefault();e.stopPropagation();}window.getSelection&&window.getSelection().removeAllRanges();};functiondragStop(){document.onmousemove=document.onmouseup=null;if(document.all){hander.onlosecapture=null;hander.releaseCapture();}else{window.onblur=null}}document.onmouseup=dragStop;};}})$=ldh.find;varAttr=function(key,value){returnvalue?(this.setAttribute(key,value),this):this.getAttribute(key)};varcommad=function(){},prevPos=0,resultList=[];ldh.each(ldh.find('INPUT'),function(){this.onclick=applySearch})functionapplySearch(){varmode='',re,beginTime=newDate;ldh.each(ldh.find('INPUT'),function(){if(this.checked)mode+=Attr.call(this,'m')});if($('#regexpText').value==''){re=null}else{try{re=newRegExp($('#regexpText').value,mode)}catch(e){re=null}}varmArr=String($('#targetText').value).match(re);$('#resultText').value='';if(!(mArrinstanceofArray))mArr=[];resultList=mArr;vartime='共耗时<strongstyle="color:#009900">'+(newDate-beginTime)+"</strong>毫秒"command(mArr,re,mode,time);}if(document.all){varrngTarget=$('#targetText').createTextRange(),firstRng=rngTarget.getBookmark();}functionfindText(text){if(!text)return;rngTarget.collapse(true);if(rngTarget.findText(text)){rngTarget.select();rngTarget.collapse(false);}else{rngTarget.moveStart('character',-$('#targetText').value.length);}};(function(){$('#regexpText').onchange=function(){resultList=[];}$('#exps1').onchange=$('#exps2').onchange=$('#exps3').onchange=function(){$('#regexpText').value=this.value;resultList=[]};($('#doFind').onclick=function(){command=function(mArr,a,b,c){$('#reInfo').innerHTML='查找结果(共找到<strongstyle="color:red">'+mArr.length+'</strong>个匹配,'+c+')';if(mArr.length==0)return$('#resultText').value='没有找到匹配项';vartxt=[];ldh.each(mArr,function(i){txt.push((i+1)+'.'+this+'\n')});$('#resultText').value=txt.join('');};applySearch();})();$('#doReplace').onclick=function(){command=function(mArr,re,b,c){$('#resultText').value=$('#targetText').value.replace(re,$('#replaceText').value);$('#reInfo').innerHTML='已替换<strongstyle="color:red">'+mArr.length+'</strong>个匹配项('+c+')'}applySearch();};$('#doTrim').onclick=function(){command=function(mArr,re,b,c){$('#resultText').value=$('#targetText').value.replace(re,'');$('#reInfo').innerHTML='已剔除<strongstyle="color:red">'+mArr.length+'</strong>个匹配项('+c+')'}applySearch();};$('#doOut').onclick=function(){command=function(mArr,re,mode,c){$('#resultText').value=$('#targetText').value.replace(re,'');$('#reInfo').innerHTML='JavaScript代码('+c+')';if(mArr.length==0)return$('#resultText').value='由于没有任何匹配项,所以未能输出正则表达式!';mode=mode?',"'+mode+'"':'';vartxt=$('#regexpText').value.replace(/\\/g,'\\\\')$('#resultText').value='myRegExp=newRegExp("'+txt+'"'+mode+');';}applySearch();};$('#doNext').onclick=function(){if(resultList.length==0){applySearch()}varm=resultList.shift()findText(m);$('#resultText').value=m?m:'没有找到匹配项';}ldh.each($('A','#tabBtns'),function(i){this.index=i;this.onkeydown=blur;this.onclick=function(){varList=$('DIV','#all_list');varBtns=$('A','#tabBtns');ldh.each(Btns,function(){this.className=''});this.className='hot';ldh.each(List,function(){this.style.display='none'});List[this.index].style.display='block';}});ldh.each([{text:'合法帐号',value:'^[a-zA-Z][a-zA-Z0-9_]{4,15}$'},{text:'图片文件',value:'.*(.jpg|.jpeg|.gif|.png)$'},{text:'E-mail',value:'^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$'},{text:'身份证',value:'^\\d{15}|\\d{18}$'},{text:'QQ',value:'^[1-9]*[1-9][0-9]*$'},{text:'全中文',value:'^[\\u4e00-\\u9fa5]+$'},{text:'手机号码',value:'^13\\d{9}|15[89]\\d{8}|189\\d{8}$'},{text:'固定电话',value:'^((\\d{3}|\\d{4})-?)?(\\d{8}|\\d{7})$'},{text:'邮政编码',value:'^[1-9]{1}(\\d+){5}$'},{text:'URL',value:'http:\/\/([\\w-]+\\.)+[\\w-]+(\/\\[\\w-.\/?%&=\\]*)?'},{text:'IP地址',value:'^(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$'},{text:'数字',value:'^[+|-]?\\d*\\.?\\d*$'},{text:'正整数',value:'^[1-9]\\d*$'},{text:'负整数',value:'^-[1-9]\\d*$'},{text:'任意整数',value:'^-?[1-9]\\d*$'},{text:'正浮点数',value:'^[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*$'},{text:'负浮点数',value:'^-([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*)$'},{text:'任意浮点数',value:'^-?([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*|0?\\.0+|0)$'},{text:'英文字母',value:'^[A-Za-z]+$'},{text:'小写英文字母',value:'^[a-z]+$'},{text:'大写英文字母',value:'^[A-Z]+$'}],function(){varO=$('#exps1').options;O[O.length]=newOption(this.text,this.value)});ldh.each([{text:'img标签',value:'<img[^>]+>'},{text:'链接',value:'<a[^>]+>(.*?)<\\/a>'},{text:'图片地址',value:'(s|S)(r|R)(c|C)*=*(\\\'|\\\")?(\\w|\\\\|\\/|\\.|:)+(\\4)'},{text:'链接地址',value:'href=(\\"|\\\'|)([^\\"\\\'<>]+)(\\1)'},{text:'中文字符',value:'[\\u4e00-\\u9fa5]'},{text:'双字节字符',value:'[^\\x00-\\xff]'},{text:'文件名',value:'([^\\\/]*?)(?:\\.\\w+)$'}],function(){varO=$('#exps2').options;O[O.length]=newOption(this.text,this.value)});ldh.each([{text:'空行',value:'\\n[\\s|]*\\r'},{text:'HTML标签',value:'<[^>]+>'},{text:'首尾空格',value:'(^\\s*)|(\\s*$)'}],function(){varO=$('#exps3').options;O[O.length]=newOption(this.text,this.value)});if(!document.all)$('#doNext').disabled=true;ldh.drag(ldh.find('#caption'),{win:ldh.find('#win'),left:0,top:0});})()</script>
  92. </body>
  93. </html>
如果您对该产品感兴趣,请填写办理(客服微信:xiaoxiongyidong)

为您推荐:

发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。