
Some Simple Examples
Searching for Elvis
Suppose you spend all your free time scanning documents looking for evidence that Elvis is still alive. You could search with the following regular expression:
1. elvis Find elvis
This is a perfectly valid regular expression that searches for an exact sequence of characters. In .NET, you can easily set options to ignore the case of characters, so this expression will match "Elvis", "ELVIS", or "eLvIs". Unfortunately, it will also match the last five letters of the word "pelvis". We can improve the expression as follows:
2. \belvis\b Find elvis as a whole word
Now things are getting a little more interesting. The "\b" is a special...