學習正則幫手笨狼正則練習器

來源:互聯網
上載者:User

<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>
<INPUT type="file" id="fileORG" onchange = "vbs:showORG"/>
<button onclick = "vbs:showORG" >載入</button>
<input type="checkbox" id="Imode" checked />忽略大小寫
<input type="checkbox" id="Gmode" checked />全域
<button onclick = "vbs:back" >清空</button>
<button onclick = "vbs:saveFile" >儲存</button><br/>
<textArea id="blockORG"></textArea><br/>
運算式:<input id="blockReg" /><br/>
替換為:<input id="replaceVar" /><input type="hidden" id="jsvalue" />
<div id="isScriptDIV">
<button id="normal" onclick="vbs:gogogo">普通替換</button>
<button id="isVBS" onclick="vbs:gogogo" >vbs運算式替換</button>
<button id="isJS" onclick="vbs:gogogo">js運算式替換</button>
</div>
<textArea id="showMe" ></textArea>
<SCRIPT LANGUAGE="vbScript">
'設定表單尺寸
window.resizeTo window.screen.availWidth,window.screen.availHeight
window.moveTo 0,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

dim fso ,Re
set Re = new RegExp
set fso = createObject("Scripting.FileSystemObject")
dim replaceStr

dim thisFileDir'定義本檔案絕對路徑
dim thisFileName'定義本檔案名稱
dim thisFileFolder'定義本檔案夾路徑

thisFileDir = replace(window.location.href,"file:///","")
thisFileDir = unescape(replace(thisFileDir,"/","\"))
thisFileName = LastOne(thisFileDir,"\")
thisFileFolder=getFolderDir(thisFileDir)

sub showORG()
'在文字框內負載檔案
dim f,ts,s
if fso.FileExists(fileORG.value) then
set f = fso.GetFile(fileORG.value)
set ts = f.OpenAsTextStream(1)
s=""
if not ts.AtEndOfStream then
s = ts.ReadAll
end if
ts.Close
blockORG.value = s
end if
end sub

Function LastOne(Str,splitStr)
'輸入字元和分隔字元,得到最後一部分
LastOne = right(Str,len(Str)-InStrRev(Str,splitStr))
End Function

function getFolderDir(fullDir)
'輸入得到全路徑,得到檔案夾路徑
s=LastOne(fullDir,"\")
getFolderDir = left(fullDir,len(fullDir)-len(s))
end function

function px2Int(px)
px2Int = cint(replace(px,"px",""))
end function

sub gogogo()
Re.IgnoreCase = Imode.checked
Re.Global = Gmode.checked
Re.Pattern = blockReg.value
replaceStr = replaceVar.value
select case window.event.srcElement.id
case "isVBS"
replaceStr = eval(replaceStr)
case "isJS"
window.execScript "jsvalue.value=eval(replaceVar.value);","javaScript"
replaceStr = jsvalue.value
end select
showMe.value = Re.Replace(blockORG.value,replaceStr)
end sub

sub back
showMe.value = ""
end sub

sub saveFile
if fso.FileExists(fileORG.value) then
set f = fso.GetFile(fileORG.value)
f.copy fileORG.value & makeRand() & ".bak"'建立備份
set ts = f.OpenAsTextStream(2)
ts.write showMe.value
ts.Close
blockORG.value = showMe.value
else
set ts = fso.OpenTextFile(thisFileFolder & makeRand() & ".txt",2,true)
ts.write showMe.value
ts.Close
blockORG.value = showMe.value
end if
end sub

function makeRand()
dim resault
resault = mid(cstr(now()),3)
resault =replace(resault,":","")
resault =replace(resault,"-","")
resault =replace(resault," ","")
makeRand = resault
end function

</SCRIPT>
</BODY>
</HTML>
笨狼正則練習器.hta

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.