學習正則幫手笨狼正則練習器
發(fā)布日期:2021-12-22 08:21 | 文章來源:腳本之家
<HTML>
<HEAD>
<TITLE>笨狼正則練習器_www.jb51.net本站</TITLE>
<style>
body
{
font-size:12;
BACKGROUND:#DADADA;
margin-left:20;
} #blockORG
{ font-family:Verdana;
font-size:12px;
overflow:scroll;
height:300; }
#fileORG
{
width:400;
}
#blockReg
{
font-family:Verdana;
font-size:12px;
}
#showMe
{
font-family:Verdana;
font-size:12px;
height:200;
overflow:visible;
}
#replaceVar
{
font-family:Verdana;
font-size:12px;
top:341;
}
#isScriptDIV
{
position:absolute;
top:361;
overflow-x:visible;
} </style>
</HEAD> <BODY>
<INPUTtype="file"id="fileORG"onchange="vbs:showORG"/>
<buttononclick="vbs:showORG">載入</button>
<inputtype="checkbox"id="Imode"checked/>忽略大小寫
<inputtype="checkbox"id="Gmode"checked/>全局
<buttononclick="vbs:back">清空</button>
<buttononclick="vbs:saveFile">保存</button><br/>
<textAreaid="blockORG"></textArea><br/>
表達式:<inputid="blockReg"/><br/>
替換為:<inputid="replaceVar"/><inputtype="hidden"id="jsvalue"/>
<divid="isScriptDIV">
<buttonid="normal"onclick="vbs:gogogo">普通替換</button>
<buttonid="isVBS"onclick="vbs:gogogo">vbs表達式替換</button>
<buttonid="isJS"onclick="vbs:gogogo">js表達式替換</button>
</div>
<textAreaid="showMe"></textArea>
<SCRIPTLANGUAGE="vbScript">
'設置窗體尺寸
window.resizeTowindow.screen.availWidth,window.screen.availHeight
window.moveTo0,0
blockORG.style.width=cint(window.screen.availWidth*0.94)
blockReg.style.width=px2Int(blockORG.style.width)-100 replaceVar.style.width=px2Int(blockReg.style.width)-400 isScriptDIV.style.left=px2Int(replaceVar.style.width)+100
showMe.style.width=blockORG.style.width dimfso,Re
setRe=newRegExp
setfso=createObject("Scripting.FileSystemObject")
dimreplaceStr dimthisFileDir'定義本文件絕對路徑
dimthisFileName'定義本文件名
dimthisFileFolder'定義本文件夾路徑 thisFileDir=replace(window.location.href,"file:///","")
thisFileDir=unescape(replace(thisFileDir,"/","\"))
thisFileName=LastOne(thisFileDir,"\")
thisFileFolder=getFolderDir(thisFileDir) subshowORG()
'在文本框內(nèi)加載文件
dimf,ts,s
iffso.FileExists(fileORG.value)then
setf=fso.GetFile(fileORG.value)
setts=f.OpenAsTextStream(1)
s=""
ifnotts.AtEndOfStreamthen
s=ts.ReadAll
endif
ts.Close
blockORG.value=s
endif
endsub FunctionLastOne(Str,splitStr)
'輸入字符和分隔符,得到最后一部分
LastOne=right(Str,len(Str)-InStrRev(Str,splitStr))
EndFunction functiongetFolderDir(fullDir)
'輸入得到全路徑,得到文件夾路徑
s=LastOne(fullDir,"\")
getFolderDir=left(fullDir,len(fullDir)-len(s))
endfunction functionpx2Int(px)
px2Int=cint(replace(px,"px",""))
endfunction subgogogo()
Re.IgnoreCase=Imode.checked
Re.Global=Gmode.checked
Re.Pattern=blockReg.value
replaceStr=replaceVar.value
selectcasewindow.event.srcElement.id
case"isVBS"
replaceStr=eval(replaceStr)
case"isJS"
window.execScript"jsvalue.value=eval(replaceVar.value);","javaScript"
replaceStr=jsvalue.value
endselect
showMe.value=Re.Replace(blockORG.value,replaceStr)
endsub subback
showMe.value=""
endsub subsaveFile
iffso.FileExists(fileORG.value)then
setf=fso.GetFile(fileORG.value)
f.copyfileORG.value&makeRand()&".bak"'創(chuàng)建備份
setts=f.OpenAsTextStream(2)
ts.writeshowMe.value
ts.Close
blockORG.value=showMe.value
else
setts=fso.OpenTextFile(thisFileFolder&makeRand()&".txt",2,true)
ts.writeshowMe.value
ts.Close
blockORG.value=showMe.value
endif
endsub functionmakeRand()
dimresault
resault=mid(cstr(now()),3)
resault=replace(resault,":","")
resault=replace(resault,"-","")
resault=replace(resault,"","")
makeRand=resault
endfunction </SCRIPT>
</BODY>
</HTML>
笨狼正則練習器.hta
<HEAD>
<TITLE>笨狼正則練習器_www.jb51.net本站</TITLE>
<style>
body
{
font-size:12;
BACKGROUND:#DADADA;
margin-left:20;
} #blockORG
{ font-family:Verdana;
font-size:12px;
overflow:scroll;
height:300; }
#fileORG
{
width:400;
}
#blockReg
{
font-family:Verdana;
font-size:12px;
}
#showMe
{
font-family:Verdana;
font-size:12px;
height:200;
overflow:visible;
}
#replaceVar
{
font-family:Verdana;
font-size:12px;
top:341;
}
#isScriptDIV
{
position:absolute;
top:361;
overflow-x:visible;
} </style>
</HEAD> <BODY>
<INPUTtype="file"id="fileORG"onchange="vbs:showORG"/>
<buttononclick="vbs:showORG">載入</button>
<inputtype="checkbox"id="Imode"checked/>忽略大小寫
<inputtype="checkbox"id="Gmode"checked/>全局
<buttononclick="vbs:back">清空</button>
<buttononclick="vbs:saveFile">保存</button><br/>
<textAreaid="blockORG"></textArea><br/>
表達式:<inputid="blockReg"/><br/>
替換為:<inputid="replaceVar"/><inputtype="hidden"id="jsvalue"/>
<divid="isScriptDIV">
<buttonid="normal"onclick="vbs:gogogo">普通替換</button>
<buttonid="isVBS"onclick="vbs:gogogo">vbs表達式替換</button>
<buttonid="isJS"onclick="vbs:gogogo">js表達式替換</button>
</div>
<textAreaid="showMe"></textArea>
<SCRIPTLANGUAGE="vbScript">
'設置窗體尺寸
window.resizeTowindow.screen.availWidth,window.screen.availHeight
window.moveTo0,0
blockORG.style.width=cint(window.screen.availWidth*0.94)
blockReg.style.width=px2Int(blockORG.style.width)-100 replaceVar.style.width=px2Int(blockReg.style.width)-400 isScriptDIV.style.left=px2Int(replaceVar.style.width)+100
showMe.style.width=blockORG.style.width dimfso,Re
setRe=newRegExp
setfso=createObject("Scripting.FileSystemObject")
dimreplaceStr dimthisFileDir'定義本文件絕對路徑
dimthisFileName'定義本文件名
dimthisFileFolder'定義本文件夾路徑 thisFileDir=replace(window.location.href,"file:///","")
thisFileDir=unescape(replace(thisFileDir,"/","\"))
thisFileName=LastOne(thisFileDir,"\")
thisFileFolder=getFolderDir(thisFileDir) subshowORG()
'在文本框內(nèi)加載文件
dimf,ts,s
iffso.FileExists(fileORG.value)then
setf=fso.GetFile(fileORG.value)
setts=f.OpenAsTextStream(1)
s=""
ifnotts.AtEndOfStreamthen
s=ts.ReadAll
endif
ts.Close
blockORG.value=s
endif
endsub FunctionLastOne(Str,splitStr)
'輸入字符和分隔符,得到最后一部分
LastOne=right(Str,len(Str)-InStrRev(Str,splitStr))
EndFunction functiongetFolderDir(fullDir)
'輸入得到全路徑,得到文件夾路徑
s=LastOne(fullDir,"\")
getFolderDir=left(fullDir,len(fullDir)-len(s))
endfunction functionpx2Int(px)
px2Int=cint(replace(px,"px",""))
endfunction subgogogo()
Re.IgnoreCase=Imode.checked
Re.Global=Gmode.checked
Re.Pattern=blockReg.value
replaceStr=replaceVar.value
selectcasewindow.event.srcElement.id
case"isVBS"
replaceStr=eval(replaceStr)
case"isJS"
window.execScript"jsvalue.value=eval(replaceVar.value);","javaScript"
replaceStr=jsvalue.value
endselect
showMe.value=Re.Replace(blockORG.value,replaceStr)
endsub subback
showMe.value=""
endsub subsaveFile
iffso.FileExists(fileORG.value)then
setf=fso.GetFile(fileORG.value)
f.copyfileORG.value&makeRand()&".bak"'創(chuàng)建備份
setts=f.OpenAsTextStream(2)
ts.writeshowMe.value
ts.Close
blockORG.value=showMe.value
else
setts=fso.OpenTextFile(thisFileFolder&makeRand()&".txt",2,true)
ts.writeshowMe.value
ts.Close
blockORG.value=showMe.value
endif
endsub functionmakeRand()
dimresault
resault=mid(cstr(now()),3)
resault=replace(resault,":","")
resault=replace(resault,"-","")
resault=replace(resault,"","")
makeRand=resault
endfunction </SCRIPT>
</BODY>
</HTML>

版權聲明:本站文章來源標注為YINGSOO的內(nèi)容版權均為本站所有,歡迎引用、轉載,請保持原文完整并注明來源及原文鏈接。禁止復制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務器上建立鏡像,否則將依法追究法律責任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學習參考,不代表本站立場,如有內(nèi)容涉嫌侵權,請聯(lián)系alex-e#qq.com處理。
相關文章