How to Specify NOT with Regular Expressions for Words
I want to filter a list of event names based on a regular expression. I can create a regular express to include (or match) name, but what would be the regular express to exclude (not match) a name?
For instance, if I want to include mouse events then the pattern would be "^Mouse". If I want all property changed events then "Changed$" is perfect. Yet, what would be the regular expression if I wanted to exclude these changed events?
Following is an example of how I plan to use the pattern.
Private _regEx As Regex
Public Sub New(ByVal pattern As String)
'pattern = "Changed$"
_regEx = New Regex(pattern)
End Sub
Private Function IsValid(ByVal eventName As String) As Boolean
Return _regEx.IsMatch(eventName)
End Function
Additionally, I want to combine the patterns. For example, I want to exclude all changed and mouse events. The opposite of "^Mouse|Changed$"