Regular Expressions

  • Thread starter Thread starter Ron Vecchi
  • Start date Start date
R

Ron Vecchi

I'm tring to figure out the expression to use to search a bunch of documents
that contain a word but do not contain a different word. Not having any
luck though!


Any ideas

Thanks for the help
 
Hi Ron,

Thank you for using the community. AS I understand, you want a Regular
Expression which can find a string including a special work, but excluding
another word. In Regular Expression, there isn't pattern for "not match".
Normally, we can perform this with two Regular Expression, for example:

Dim re1 As New System.Text.RegularExpressions.Regex("abc")
Dim re2 As New System.Text.RegularExpressions.Regex("def")


Dim s1 As String = "abcdef"
Dim s2 As String = "123abc"


If re1.IsMatch(s1) And (Not re2.IsMatch(s1)) Then
MsgBox(s1 & " is matched")
End If

If re1.IsMatch(s2) And (Not re2.IsMatch(s2)) Then
MsgBox(s2 & " is matched")
End If

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
If you have massive amounts of data consider Index server. Regex while very
good on small strings will be a hinder on a large volume (at least in my
experience)
-Arthur
 
Back
Top