中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [推荐]正则表达式Regex文章收集
« [1] [2] »
作者:
标题: [推荐]正则表达式Regex文章收集 上一主题 | 下一主题
amao
中级用户





积分 316
发帖 152
注册 2006-6-18
状态 离线
『第 16 楼』:  

版主最近做的这几件事,真是意义重大啊。

2006-10-27 01:55
查看资料  发短消息 网志   编辑帖子  回复  引用回复
112183883
初级用户





积分 128
发帖 31
注册 2006-10-23
状态 离线
『第 17 楼』:  

贡献一个偶写的一个正则校验器,可作简单正则校验,



测试效果:



需要的朋友可以去http://www.w3cg.net/blog/article.asp?id=56下载

2006-10-27 08:10
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
electronixtar
铂金会员





积分 7493
发帖 2672
注册 2005-9-2
状态 离线
『第 18 楼』:  

好东西!下次我贴一个hta做的




C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
2006-10-27 12:20
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
112183883
初级用户





积分 128
发帖 31
注册 2006-10-23
状态 离线
『第 19 楼』:  

呵呵,我也喜欢用HTA做东西,以前用它做过同学录通讯软件,前台用HTA+AJAX,后台用ASP,前台在自己机器上,后台放在服务器上,蛮好。还做过一个小工具,将BAT文件转成VBS文件,呵呵。

HTA是个不错的软件设计方式,可惜微软不继续搞了,要不然多给它点支持,还能做出好多好东西来。

2006-10-27 14:49
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
electronixtar
铂金会员





积分 7493
发帖 2672
注册 2005-9-2
状态 离线
『第 20 楼』:  



  Quote:
将BAT文件转成VBS文件

放上来看看啊,我把验证RegExp的也放上来




C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
2006-10-27 22:58
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
electronixtar
铂金会员





积分 7493
发帖 2672
注册 2005-9-2
状态 离线
『第 21 楼』:  

Regular Expression Tester
http://www.visualbasicscript.com/m_35894/tm.htm
<html>
<head>
<title>Regex Tester</title>
<HTA:APPLICATION
icon = "c:\icons\hate.ico"
Caption = "yes"
Version = "2.5"
/>
<!-- Author : Mike D Adams [email=Mikeock01@hotmail.com]Mikeock01@hotmail.com[/email]
Thanks to Jared Franklin for the submatches portion.
Thanks to all the suggestion and help from the users of the visualbasicscript.com forums
2006/07/25
-    Added tool-tips on text areas for exp and string
-    Changed the color of all text areas to match the "theme" of the app
2006/07/24
-     fixed some issues in the text processing portion (load/unload files)
-    Added Tooltips for almost all buttons
-    Disabled other file options once you have one selected
-    Renamed close button to hide. Clarity sake
-    Changed the file text to blue w\ a size of +1
-    Added tooltips to the checkboxes
-    Jumped version number to 2.5 (from 2.0)-->
<script language="VBScript">
'#################### Start VBScript Section ####################

''= refreshes the HTA page, which includes re-running any Windows_Onload code
'' ============================================================================
Sub reloadHTA()
location.reload( True )
End Sub

'Sub to Run when Test RegEx button is pressed
sub cmdTextBox
dim string1, Re,s,colMatches,Test,ResultArr()

'Configure Regular Expression
set Re = new RegExp
Re.Pattern = ExprStrin.TextBox.value

' Error if pattern is blank
if Re.Pattern = "" Then
       strError = "<font color=red>Please enter a Regular Expression!</font>"
   DataAr1.InnerHTML = strError
   SubAr1.InnerHTML = strError
   strError = ""

'Move on pattern is not blank
else
   If ExprStrin.GlobalCheckBox.checked Then    'Set Global attribute according to checkbox
       Re.Global = true
   Else
       Re.Global = false
   End If
  
   If ExprStrin.caseCheckbox.checked Then    'Set IgnoreCase attribute according to checkbox
       Re.IgnoreCase = True
   Else
       Re.IgnoreCase = False
   End If

   If ExprStrin.MultilineCheckBox.checked Then    'Set Multiline attribute according to checkbox
         Re.Multiline = True
     Else
         Re.Multiline = False
     End If

   s = ExprStrin.StringBox.value
  
   'Error if string to search is blank
   if s = "" Then
           strError = "<font color=red>Search String cannot be left blank!</font>"
       DataAr1.InnerHTML = strError
       SubAr1.InnerHTML = strError
       strError = ""
      
   ' Test regex if string is not blank
   else
  
       'If a match is found...
       if Re.Test(s) then
           'Collect and Output Matches
           Set colMatches = Re.Execute(s)
           counter = 0
           numMatches = colMatches.count
           for each Test in colMatches
               ReDim Preserve ResultArr(counter + 1)
               ResultArr(counter) = Test.value
               counter = counter + 1
           next
           dim tempstring
           for count2 = 0 to counter - 1
               tempstring = tempstring & "<b>Match " & count2+1 & ": </b>" & ResultArr(count2) & "<br>"
           next
           DataAr1.InnerHTML = "<b>The following matches were found:</b><br>" & tempstring
         
           'Collect SubMatches and Store them in a String
           subMatchesString = ""
           For i=0 to numMatches-1    'Loop through each match
               Set myMatch = colMatches(i)
               numSubMatches = myMatch.submatches.count
               If numSubMatches > 0 Then    'Loop through each submatch in current match
                   subMatchesString = subMatchesString & "<b>Submatches for Match " & i+1 & "</b><br>"
                   For j=0 to numSubMatches-1
                       subMatchesString = subMatchesString & myMatch.SubMatches(j) & "<br>"
                   Next
               End If
           Next
         
           'Output submatches to correct field
           SubAr1.InnerHTML = subMatchesString
              
       'If no match is found output error and sub strings
       else
           DataAr1.InnerHTML = "No match was found for the regular expression."
           ClearSubs
       end if
   end if
end if

'Clear things up
Set Re = Nothing
Set colMatches = nothing
end sub

'Sub to Run when Clear Results and submatches when button is pressed
sub ClearDataAr1
DataAr1.InnerHTML = "Results Cleared!"
SubAr1.InnerHTML = "Results Cleared!"
end sub


sub loadfiles
retVal = "<input type=file name=xmlname> <br> <input type=button value=Assimilate onclick=fileLoader Title=""Click to load settings into App"">"
Loader.InnerHTML = retVal
ExprStrin.Saver.disabled = True
ExprStrin.Templ2.Disabled = True
exprstrin.xmlname.style.backgroundcolor = "C0C0C0"
end sub

sub CloseFile
Loader.InnerHTML = ""
Loader2.InnerHTML = ""
ExprStrin.Loader.Disabled = False
ExprStrin.Saver.disabled = False
ExprStrin.Templ2.Disabled = false
end sub

sub fileLoader
set fileObj = CreateObject("Scripting.FileSystemObject")
if ExprStrin.xmlname.value = "" then
     Loader2.InnerHTML= "<font color=red>Enter a filename</font>"
else
     file = ExprStrin.xmlname.value
end if
if fileObj.FileExists(file) then
     set objStream = fileObj.OpenTextFile (file, _
         1,false,0)
     opened = true
else
     Loader2.InnerHTML= "<font color=red size=+1>File not found</font>"
     opened = false
end if
if opened then
     Loader2.InnerHTML= ""
     contents = ObjStream.Readall
     contents2 = split(contents,"-------")
     expr = Replace(contents2(0),VbnewLine,"")
     if instr(len(contents2(1))-1,contents2(1),vbnewline) then
         stringer = Left(cstr(contents2(1)),len(cstr(contents2(1)))-2)
         stringer = right(stringer,len(stringer) -2 )
     else
         Stringer = contents2(1)
     end if
     ig = Replace(contents2(2),vbnewline,"")
     gs = Replace(contents2(3),vbnewline,"")
     ml = Replace(contents2(4),vbnewline,"")
     'Set hta vars back to loaded values
     ExprStrin.TextBox.value = expr
     ExprStrin.StringBox.value = Stringer
     if ig then
         ExprStrin.caseCheckbox.checked = True
     else
         ExprStrin.caseCheckbox.checked = False
     end if
     if gs then
         ExprStrin.GlobalCheckBox.Checked = True
     else
         ExprStrin.GlobalCheckBox.Checked = false
     end if
     if ml then
         ExprStrin.MultilineCheckBox.checked = true
     else
         ExprStrin.MultilineCheckBox.checked = False
     end if
else
     expr =""
     stringer = ""
     ig = ""
     gs = ""
     ml = ""
end if
set fileObj = Nothing
End sub

sub TmpInner
Loader2.InnerHTML = ""
Loader.InnerHTML= "Enter a filename for template<br>" & _
                   "<input type=""Text"" ""id=Templ"" name=""Templ"" value="""">" & _
                   "<input type=""Button"" value=""Save"" onClick=""SaveTmpl"" Title=""Click after entering filename for template to be created"">"
ExprStrin.Loader.Disabled = true
ExprStrin.Saver.disabled = true
ExprStrin.Templ.style.backgroundcolor = "C0C0C0"

end sub

sub SaveTmpl
set fileObj = CreateObject("Scripting.FileSystemObject")
file = ExprStrin.Templ.value
if file = "" then
     Loader2.InnerHTML = "<font color=red size=+1>Enter a FileName</font>"

else
     if not (fileObj.FileExists(file)) then
         Loader2.InnerHTML = "File not found. Creating now"
         set file2 = fileObj.CreateTextFile(file)
     else
         Loader2.InnerHTML = "File existed. Over-writing now!"
         set file2 = fileObj.CreateTextFile(file,True)
     end if
     file2.writeline ("'Remove this line and put expr here")
     file2.WriteLine ("-------")
     file2.WriteLine ("'Remove this line and enter in string.. Can be multi line")
     file2.WriteLine ("-------")
     file2.WriteLine ("'Remove this line. Enter boolean of Ignore case value")
     file2.WriteLine ("-------")
     file2.WriteLine ("'Remove this line. Enter boolean of Global Search value ")
     file2.WriteLine ("-------")
     file2.WriteLine ("'Remove this line. Enter boolean of MultiLine value")
     file2.close
end if
set fileObj = nothing
end sub

sub SaveSets
Loader2.InnerHTML = ""
'load txtbox for save value
Loader.InnerHTML= "Enter a filename to save<br>" & _
                   "<input type=""Text"" ""id=Templ"" name=""Templ"" value="""">"  & _
                   "<input type=""button"" value=""Save"" onclick=""SaveSets2"" Title=""Click after entering a filename to save"">"
ExprStrin.Loader.Disabled = True   
ExprStrin.Templ2.Disabled = True
ExprStrin.Templ.style.backgroundcolor = "C0C0C0"
end sub

sub SaveSets2
set fileObj = CreateObject("Scripting.FileSystemObject")
file = ExprStrin.Templ.value
'open file for writing
if file = "" then
     Loader2.InnerHTML = "<font color=red size=+1>Enter a FileName</font>"
else
     if not (fileObj.FileExists(file)) then
         Loader2.InnerHTML = "File not found. Creating now"
         set file2 = fileObj.CreateTextFile(file)
     else
         Loader2.InnerHTML = "File existed. Over-writing now!"
         set file2 = fileObj.CreateTextFile(file,True)
     end if
     delim = "-------"
     file2.writeline(ExprStrin.TextBox.value)
     file2.writeline(delim)
     file2.writeline(ExprStrin.StringBox.value)
     file2.writeline(delim)
     file2.writeline( ExprStrin.caseCheckbox.checked)
     file2.writeline(delim)
     file2.writeline(ExprStrin.GlobalCheckBox.Checked)
     file2.writeline(delim)
     file2.writeline(ExprStrin.MultilineCheckBox.checked)
     file2.close
End if
     set fileObj = nothing
end sub

sub Window_onload
ExprStrin.TextBox.style.backgroundcolor = "C0C0C0"
ExprStrin.StringBox.style.backgroundcolor = "c2c2c2"
end sub
'#################### End VBScript Section ####################
</script>
</head>


<body STYLE="filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#c2c2c2', EndColorStr='#00CCFF')">
<form action="some_form_handler.asp" method="post" id="ExprStrin" name="ExprStrin" target="_self">
<center><h1>Regex Tester</font></h1></center>
   <table align="center">
   
       <tr>
           <td>Enter an expression</td>
           <td><input type="text" id="TextBox" name="TextEntry" value="" tabindex=1 size=66 title="Enter a valid regular expression here"></td>
       </tr>
       <tr>
           <td>Enter a string</td>
           <td><textarea cols=50 rows=4 name="StringBox" tabindex=2 Title="Enter in a string to test Regular expression against"></textarea>
           </td>
       </tr>
   </table>
     <!-- Check boxes and main button locations -->
   <table align="center" cellpadding="5">
       <tr>
           <td><input type=checkbox name="IgnoreCase" ID="CaseCheckBox" tabindex=3 title="Allows the ability to ignore case sensitivity">Ignore Case</td>
           <td><input type=checkbox name="Global" id="GlobalCheckBox" tabindex=4 checked="true" Title="Allows the ability to search the whole string">Global Search</td>
           <td><input type=checkbox name="Multiline" id="MultilineCheckBox" tabindex=5 title="Allows the ability to search multiple line strings">Multiline</td>
           </tr>
           <tr>
           <td><input type="button" value="Clear Results" onClick="ClearDataAr1" size=30 tabindex=6 Title="Clear the results area"></td>
           <td><input type="button" value="Test RegEx" onClick="cmdTextBox" tabindex=7 title="Test regular expression"></td>
           <td><input type = "BUTTON" value = "Reload" onclick = "reloadHTA()"tabindex=8 title="Reload App with default values" ></td>
       </tr>
   </table>

   <table align="center" cellpadding="5">
       <tr>
           <td><br><font color=blue size=+1><b>Error or Result display</b></font></td>
       </tr>
   </table>
   <table align="center" >
       <tr>
           <td><span id=DataAr1>Result will display here</span></td>
       </tr>
   </table>
   <table align="center" ID="Table1" cellpadding="5">
       <br>
       <tr><td><font color=blue size=+1><b>Substring Matches Display</b></font></td></tr>
   </table>
   <table align=center >
       <tr>
           <td><span id=SubAr1>Substrings will display here</span></td>
       </tr>
   </table>
   <table align=center cellpadding="5"><br><br>
     <tr>
         <td><font color=blue size=+1>Import/Export data from file</font><br><input type="button" value="Load" onClick="loadfiles" id="loader" Title="Select to enable loading options">
             <input type="button" value="Template" onClick="TmpInner" id="Templ2" Title="Allows the creation of a default template">
             <input type="button" value="Save" onclick="SaveSets" id="Saver" Title="Allows you to save current settings to a file">
             <input type="button" Value="Hide" onClick="CloseFile" Title="Hides save/template options"></td>
   </tr>
     <tr>
     <td><span id=Loader></span></td>
     </tr>
     <tr><td><span id=Loader2></span></td></tr>
</table>
</form>
</body>
</html>





C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
2006-10-27 23:04
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
112183883
初级用户





积分 128
发帖 31
注册 2006-10-23
状态 离线
『第 22 楼』:  



  Quote:
Originally posted by electronixtar at 2006-10-27 10:58 PM:
放上来看看啊,我把验证RegExp的也放上来

那个小东东都不知道被我丢到哪里去了哦...

2006-10-29 08:30
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
scriptor
银牌会员




积分 1187
发帖 555
注册 2006-12-21
状态 离线
『第 23 楼』:  

正则表达式好像有点难度阿

不过他是很有用的阿

要学,。。。

2006-12-28 01:06
查看资料  发短消息 网志   编辑帖子  回复  引用回复
verber34
初级用户





积分 52
发帖 19
注册 2006-9-8
状态 离线
『第 24 楼』:  



  Quote:
Originally posted by 无奈何 at 2006-10-26 11:43:
深入浅出之正则表达式(一)
原贴地址:http://dragon.cnblogs.com/archive/2006/05/08/394078.html

前言:
       半年前我对正则表达式产生了兴趣..

好东西~~

里面的有些东西怎么不正确显示?? 我已找到了正确显示的。

2007-1-5 07:10
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
estar
中级用户





积分 346
发帖 103
注册 2004-4-6
状态 离线
『第 25 楼』:  

今天发现了一个好东东,PowerGREP,没想到在CN-DOS早就有人用了,顶啊。

2007-4-19 12:57
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
lililulula
中级用户





积分 302
发帖 138
注册 2007-3-29
状态 离线
『第 26 楼』:  

以前有用过怎么校验中文的输入,不过自己不理解~~~以后需要用的时候再突击吧~~~

2007-4-19 22:52
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
wydos
中级用户





积分 304
发帖 117
注册 2006-4-4
状态 离线
『第 27 楼』:  

太多了,看不过来,先收藏了!!!

2007-4-20 00:53
查看资料  发送邮件  发短消息 网志  OICQ (327337973)  编辑帖子  回复  引用回复
« [1] [2] »
请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: