Sunday, June 28, 2009

RegEx – Preventing matches based on specific characters

from: Finding lines not containing certain words

use the Prevent Match expression:

~(X) Prevents a match when X appears at this point in the expression. For example, real~(ity)matches the "real" in "realty" and "really," but not the "real" in "reality."

Eg: used in the blog post:

{public ~(const|event|delegate|readonly|static readonly|static extern|abstract).*};$ 
finds all public members in C# code.

1 comment:

.net development said...

Great Post! Really very useful one. Thanks.