Array | filename | regular
Today, Zblog upload module, need to use a process to extract the file name of the child, the beginning of the problem I want to complicate, matching all possible file names, not only regular expression wrote a large string, and below also split for half a day, Later I suddenly found z-blog upload files are upload, White wrote so many complex matching ... Hey, can not be wasted ah, or posted up in case of any brothers need to take to use ~ ~
The following is basically a good generic match. PS: I suddenly discovered that Code_lite had escaped my UBB!!! Dizzy, I had to escape ... )
--------------------------------------------------------------------------------
Dim objregexp, Matches,i,dc9_dot_cn_match
Dim arymatch ()
Redim Preserve arymatch (0)
Set objregexp=new RegExp
Objregexp.ignorecase =true
Objregexp.global=true
objregexp.pattern= "(?: \ [[^\]]+\]([^\[]+)\[\/[^\]]+\])| (?:(: HREF|SRC) = ([^\s|^>]+) ["|>|\s\ '])"
Set matches = Objregexp.execute ("hh<a href= "" http:// Www.dc9.cn/ddd.jpg "" ></a > href= "" [Img_right=400,300,title]upload/2assas.jpg[/img_right] http://www.dc9.cn/dccdd.jpg "" >[img_right=400,300,title]upload/2assas.jpg[/ Img_right]<sctipt src= " http://www.dc9.cn/upload/sss.jpg " "")
Dim Tmpmatch
for I=0 To Matches.count-1
Call Insertdatatoarray (matches (i). Submatches (0), Arymatch)
Call Insertdatatoarray (matches (i). Submatches (1), Arymatch)
Next
For i=0 to Ubound (Arymatch)
If not IsNull (Arymatch (i)) and Trim (Arymatch (i)) <> "Then Response.Write Arymatch (i) &" <br> "
Next
Function Insertdatatoarray (Data,byref arymatch)
If Trim (Data) <> "Then
Data=replace (Data, "'", "")
Data=replace (Data, "" "", "")
Data=replace (Data, "\", "/")
Data=split (data, "/") (Ubound (Split (Data, "/"))
Redim Preserve Arymatch (Ubound (arymatch) +1)
Dc9_dot_cn_match=false
For j=0 to Ubound (Arymatch)
If Arymatch (j) =data Then Dc9_dot_cn_match=true
Next
If not Dc9_dot_cn_match Then arymatch (Ubound (arymatch)) =data
End If
End Function
--------------------------------------------------------------------------------
In fact, z-blog words on the match upload on it (but I for the sake of easy, but also in order to more accurate, just above the match above add a upload, so it looks as if the following this more complex, in fact theoretically should be the following this simple, after all, there are upload tube. And don't have to split that/. So write it:
--------------------------------------------------------------------------------
Dim objregexp, Matches,i,zc_upload_match
Dim arymatch ()
Redim Preserve arymatch (0)
Set objregexp=new RegExp
Objregexp.ignorecase =true
Objregexp.global=true
objregexp.pattern= "(?: \ [[^\]]+\][^\[]*upload\/([^\[|^\\|^\/]+) \[\/[^\]]+\]) | (?:(: HREF|SRC) = "" {0,1}[^\s|^ "" |^>|^ "]*upload\/([^\s|^>]+) [" |>|\s\ ']) "
Set matches = Objregexp.execute ("hh <a href=" "http:// Www.dc9.cn/ddd.jpg "" ></a > href= "" [Img_right=400,300,title]upload/2assas.jpg[/img_right] http://www.dc9.cn/dccdd.jpg "" >[img_right=400,300,title]upload/2assas.jpg[/ Img_right]<sctipt src= "" http://www.dc9.cn/uPload/sss.jpg "Src=http://www.dc9.cn/upload/sasds.jpg ' >")
Dim Tmpmatch
for i=0 to Matches.count-1
Call Insertdatatoarray (matches (i). Submatches (0), Arymatch)
Call Insertdatatoarray (matches (i). Submatches (1), Arymatch)
Next
For i=0 to Ubound (Arymatch)
If not IsNull (Arymatch (i)) and Trim (Arymatch (i)) <> "Then Response.Write Arymatch (i) &" <br> "
Next
Function Insertdatatoarray (Data,byref arymatch)
If Trim (Data) <> "Then
Data=replace (Data, "'", "")
Data=replace (Data, "" "", "")
Redim Preserve Arymatch (Ubound (arymatch) +1)
Zc_upload_match=false
For j=0 to Ubound (Arymatch)
If Arymatch (j) =data Then Zc_upload_match=true
Next
If not Zc_upload_match Then arymatch (Ubound (arymatch)) =data
End If
End Function
Source:http://www.dc9.cn/post/279.html