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:

Remember, if you want me to respond to your comment, then you need to use a Google/OpenID account to leave the comment.