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!

Is it possible to have multi patterns in RegEx?

Status
Not open for further replies.

markdmac

MIS
Dec 20, 2003
12,340
US
I'm piping the output of a command box into a variable which I then turn into an array. I'm looping through the array and I'm trying to look for multiple words in the text.

Is this possible?

I want to search for each of the following:
Server:
Address:
Microsoft (R)
Copyright (C)

If my match count is greater than 0 then I want to ignore that line.

Here is what I have so far that works great for searching one of my criteria.

I'm coding in vbscript but have found in the past that RegEx is virtually the same in JavaScript.

Code:
nslookupinfo = Split(strNsLookupStdOut,vbCr)
'Declare our variable
	Dim objRegExpr

	'Create an instance of the regexp object
	Set objRegExpr = New RegExp
	objRegExpr.Pattern = "Address:"
	objRegExpr.Global = True
	objRegExpr.IgnoreCase = True

For Each line In nslookupinfo
	Set colMatches = objRegExpr.Execute(line)
	If colMatches.Count = 0 Then
	  If Len(line) > 2 Then
		WScript.echo line
	  End If
	End If
Next

I guess what I am trying to do is get something like this to work:

objRegExpr.Pattern = "Server:" OR "Address:"

But that syntax is bad. Does anyone know if this is possible or do I need to nest expressions?

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Solution found:

objRegExpr.Pattern = "Address:|Server:"

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top