Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cscript - vbscript regexp - still having problems

Status
Not open for further replies.

cisco777

Programmer
Jul 22, 2005
13
US
1. I did not want to start a new thread but i do not see either a reply or email link on the post 1096693 to use as a reply to, so i do not know how to respond to thread 1096693 or any existing threads since there is no clear reply or respond to.

2. I appreciate the help and i thought with the regexp i was supposed to:
first - establish the main string with the string to search code
second - then the pattern was used to look up the substring that is within that main string.

so i was using the sub string of "in error" to look in the main string that contains "ended in error".

that is what i read somewhere and is why i did it this way. this is my first try.

3. I ran the below code and recieved error - invalid call or procedure for the line that says -
Set tx = objFSO.OpenTextFile("c:\errorfile.log", ForReading)

4. lastly what does -\bwith\b\s+\bhas errors\b mean?
I have not used regexp till now and do not know what bwith means?

thank you.

steve

code follows:

Create File System Objects
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")

Set tx = objFSO.OpenTextFile("e:\Upload\log\HLITestLogFolder\errorfile.log", ForReading)

'StringToSearch = "Ended with errors "

StringToSearch=objtxt.readall
tx.close

Set tx = Nothing
Set objFSO = Nothing

Set StdOut = WScript.StdOut

' Set up the string that will be searched for the existence of a sub-string
' Pattern specifies the Regular Expression that is to be searched for
' False = Only match the first occurence of the pattern

StdOut.WriteLine "Contents of StringToSearch = " & StringToSearch

Set RegularExpressionObject = New RegExp
With RegularExpressionObject
.Pattern = "\bwith\b\s+\bhas errors\b"
.IgnoreCase = True
.Global = False
End With

expressionmatch = RegularExpressionObject.Test(StringToSearch)

If expressionmatch Then
StdOut.WriteLine "RegularExpressionObject.Pattern match was found in " & StringToSearch
Else
StdOut.WriteLine "RegularExpressionObject.Pattern match was Not found in " & StringToSearch
End If

Set RegularExpressionObject = Nothing
set objStdOut = Nothing

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top