fischadler
Programmer
I am very new to regular expressions. I have the code below which I use to find news records which match a particular pattern:
This code is inside a loop which goes through a series of records, and stripHTMLtags is a function to remove HTML tags.
This code works fine when looking for all articles which have either the word "cat" OR the word "dog". But I want to set it to find only the articles which have both "cat" AND "dog".
Tried replacing the "Pipe" character with other characters to no avail.
-Fischadler
Code:
strPattern = "(cat)|(dog)"
StrippedString = stripHTMLtags(rstNews("NewsDetails"))
Set RegularExpressionObject = New RegExp
With RegularExpressionObject
.Pattern = strPattern
.IgnoreCase = True
.Global = True
End With
Set ExpressionMatch = RegularExpressionObject.Execute(StrippedString)
If ExpressionMatch.Count > 0 Then
'Do something
END IF
This code is inside a loop which goes through a series of records, and stripHTMLtags is a function to remove HTML tags.
This code works fine when looking for all articles which have either the word "cat" OR the word "dog". But I want to set it to find only the articles which have both "cat" AND "dog".
Tried replacing the "Pipe" character with other characters to no avail.
-Fischadler