Forum Moderators: open

Message Too Old, No Replies

regexp implementation help (vbscript)

regexp implementation help (vbscript)

         

grobar

6:58 pm on Aug 13, 2006 (gmt 0)

10+ Year Member



Okay, so ive got a regexp that works perfectly in an online tester. I am having trouble implementing in my existing code.

It takes a variable (xmlhttp.responseText) that holds an external page's source code, and checks it for the existance of a link to a specified domain. It should then show ONLY the HTML for that link, and then break it up in the sub strings.

What it DOES do currently, is return the whole string, EXCEPT the link it should, in effect doing the opposite.

Any help is appreciated. Source code i'm checking against to test is <snip> and looking for the link to <snip>

The VB code thus far:


url = objRSanc("la_blt_link_url")

set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP")
on error resume next
xmlhttp.open "GET", url, false
xmlhttp.send ""

if err.number <> 0 then
VerifyUrl=false
response.redirect("http://www.google.com/?0000000000000000000000")
else

set regizzo = New RegExp
regizzo.Pattern = "(<[^>]*?a[^>]*?(?:billiardsforum.info)[^>]*>)((?:.*?(?:<[ \r\t]*a[^>]*>?.*?(?:<.*?/.*?a.*?>)?)*)*)(<[^>]*?/[^>]*?a[^>]*?>)"

regizzo.Global = True
regizzo.IgnoreCase = True

dim stipulation

stipulation = regizzo.replace(xmlhttp.responseText, "$2")

response.write stipulation


Set regizzo = Nothing

dim updiz
Set updiz = Server.CreateObject("ADODB.Connection")
updiz.Open strdbee
Set objRSupd = Server.CreateObject("ADODB.RecordSet")

strsqlu = "UPDATE la_blt SET la_blt_link_anchor='somevar' WHERE la_blt_id =44"
objRSupd.Open strSQLu, updiz, adLockOptimistic

end if

response.write("done.")
%>

[edited by: engine at 4:17 pm (utc) on Aug. 14, 2006]
[edit reason]
[1][edit reason] No urls, thanks. See TOS [webmasterworld.com] [/edit]
[/edit][/1]

wardbekker

12:43 pm on Aug 17, 2006 (gmt 0)

10+ Year Member



Hi grobar,

Without reading the regex pattern; is the group position "$2" the correct one? Maybe it should be $1 or $3, or..? Or am i talking nonsense here? ;-)

Good luck,

Ward