in .NET Framework

Match Whole Words Regular Expressions

Example:

Dim regExp As New Regex(String.Format(“\b{0}\b”, keyword), RegexOptions.IgnoreCase)

This is the same as doing the following:


1
2
3
note.note_content.StartsWith(InputKeyword & " ") OR _
note.note_content.EndsWith(" " & InputKeyword) OR _
note.note_content.Contains(" " & InputKeyword & " ")

References:

http://answers.oreilly.com/topic/217-how-to-match-whole-words-with-a-regular-expression/

http://stackoverflow.com/questions/810078/search-for-whole-word-with-linq-to-sql

  • Related Content by Tag