RegEx and Search String

Hi All,

I’m hoping someone can help me with the correct RegEx search string to achieve the following. For example, I have in a TextField the text “Cat, Dog, Mouse”. I’m trying to create a RegEx search string that will return a positive match only if Cat and Mouse are found.

Example Text

“Cat, Dog, Mouse”

I’ve tried the following code.

[quote]Dim rg As New RegEx
Dim myMatch As RegExMatch

rg.SearchPattern = “Cat” + “|” + “Mouse”

myMatch = rg.Search(InputTextArea.Text)

If myMatch <> Nil Then

'StatusTextField.Text = myMatch.SubExpressionString(0)

StatusTextField.Text = “SUCCEEDED”

StatusTextField.Text = “Text not found!”
End If
Exception err As RegExException

However this seems to return results if Cat or Mouse is found. I’m trying to return a positive result only if Cat and Mouse are found.

Any help appreciated.

Thank you.

Are end-of-lines a factor? Would “Category” count for “cat”? Does order matter?

Hi Kem,

Thanks for the reply. In answer to your questions.

Q. Are end-of-lines a factor?
A. I don’t believe so.

Q. Would “Category” count for “cat”?
A. Assuming I understand the question. If the text contained Category and the search pattern contained Cat, this would return a positive result, this is OK.

Q. Does order matter?
A. No - the text could be “Mouse, Cat, Dog” or “Mouse, Dog, Cat” etc.

Thank you.


Thanks Kem, worked perfectly. Thanks again…