Petri IT Knowledgebase Forums
 

Petri.co.il forums Home Forums Start Page Forums Frequently Asked Questions FAQ Member List Members List
Go Back   Petri IT Knowledgebase Forums > Windows Scripting > Windows Script Host
Petri.co.il is happy to award auglan the title of Most Valuable Member !!!
Register Calendar Calendar Search Petri IT Knowledgebase Forums Search Todays Posts Today's Posts Mark Forums Read

Notices

Regular expression in VBScript

Regular expression in VBScript

this thread has 2 replies and has been viewed 986 times

Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1  
Old 27th June 2012, 12:04
h0ndzik h0ndzik is offline
Casual
Casual
 
 Join Date: Jun 2010
  6 month star 12 month star
 Posts: 20
 Reputation: h0ndzik is on a distinguished road (10)
Default Regular expression in VBScript

Hi all
I have script which get http content and then search string. But when I want use regular in search string, it not work (regular: .*?). Also I using double quotes marks to express single quote mark.
Any idea how rewrite script? Search string with regular works fine outside vscript
Best regards.

Code:
server = "1.2.3.4"
link = "/443/link"
Set Http = CreateObject("WinHttp.WinHttpRequest.5.1")
Http.SetClientCertificate "LOCAL_MACHINE\MY\cert"
Http.Option(4) = 256 + 512 + 4096 + 8192 
Http.Open "GET", "https://" & server & ":" & link, false
Http.Send
out = Http.ResponseText

If InStr(1,out,"banner:apps:1:app:link::ILinkListener::"".*?class=""selected""") Then
wscript.echo "ok"
Else
wscript.echo "error"
End If

Set Http = Nothing
  #2  
Old 28th June 2012, 14:10
Rems's Avatar
Rems Rems is offline
Moderator
 
 Join Date: Mar 2005
  6 month star 12 month star
 Location: NL
 Posts: 2,265
 Reputation: Rems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to behold (903)
Default Re: Regular expression in VBScript

you can try,
Code:
Set Http = CreateObject("WinHttp.WinHttpRequest.5.1")

server = "1.2.3.4"
link = "/443/link"

With Http
   .SetClientCertificate "LOCAL_MACHINE\MY\cert"
   .Option(4) = 256 + 512 + 4096 + 8192 
   .Open "GET", "https://" & server & ":" & link, false
   .Send
   out = .ResponseText
End With

Set Http = Nothing


Set re = new regexp : re.Global = true : re.IgnoreCase = true

wildcard = ".*?"
re.Pattern = "banner:apps:1:app:link::ILiNKListener::""" & wildcard & "class=""selected"""

If re.Test(out) then
   wscript.echo "ok"
Else
   wscript.echo "error"
End If
/Rems
__________________

This posting is provided "AS IS" with no warranties, and confers no rights.

__________________

** Remember to give credit where credit's due **
and leave Reputation Points for meaningful posts
  #3  
Old 28th June 2012, 17:45
h0ndzik h0ndzik is offline
Casual
Casual
 
 Join Date: Jun 2010
  6 month star 12 month star
 Posts: 20
 Reputation: h0ndzik is on a distinguished road (10)
Default Re: Regular expression in VBScript

Hi Rems, thank you very much for help! It works now.
Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Assistance with an expression using Report Builder 3.0 Virtual SQL Server 2008 / R2 0 23rd April 2012 16:37
VBScript in Windows server 2008 R2 (VBScript 5.8), I cannot seem to find anything Chromebuster General Scripting 9 28th February 2011 14:10
Wireshark - queries/filter/expression for nbns glacieredlightning General Networking 5 25th November 2008 22:14
VBScript - Trapping Control-CI have some vbscript running in the cscript host for whi humbletech99 General Scripting 0 27th December 2007 15:40
active directory search expression jarvip Active Directory 3 9th December 2006 21:41


All times are GMT +3. The time now is 04:28.

Steel Blue 3.5.4 vBulletin Style ©2006 vBEnhanced
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
 

Valid XHTML 1.0!   Valid CSS!

Copyright 2005 Daniel Petri