Skip navigation.

Accepting Submissions For The Hall Of FameAll recent postsHow Hot Thou Art

Peculiar RegEx Classes

While doing research for my post Unicode in Visual Studio.NET 2003 I came across a bunch of interesting classes in the System.Web.RegularExpressions assembly. These classes seem to be used quite extensively by the page parser which takes apart ASPX files. They search for tags, comments, server-side directives, etc.

You can find them in System.Web.RegularExpressions.dll. If you don't see it in your Reflector load the DLL from C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 or whatever the appropriate path is on your box.

Here's a rundown on the classes I'm talking about:

namespace System.Web.RegularExpressions
{
    public class AspCodeRegex : Regex {}
    public class AspExprRegex : Regex {}
    public class CommentRegex : Regex  {}
    public class DatabindExprRegex : Regex {}
    public class DataBindRegex : Regex {}
    public class DirectiveRegex : Regex {}
    public class EndTagRegex : Regex {}
    public class GTRegex : Regex {}
    public class IncludeRegex : Regex {}
    public class LTRegex : Regex {}
    public class RunatServerRegex : Regex {}
    public class ServerTagsRegex : Regex {}
    public class SimpleDirectiveRegex : Regex {}
    public class TagRegex : Regex {}
    public class TextRegex : Regex {}
}

Most class names are pretty self explanatory. If you're writing some kind of a parser, check out class constructors and reuse their RegEx expressions. Why reinvent the wheel, right?

Interestingly enough, each one of these classes uses a corresponding RegexRunnerFactory which is, ahem, "not intended to be used directly from your code." These factories handle heavy lifting of running searches. If you're really hardcore into it, I think you'll find these "runners" interesting.

Comments

No comments yet

Emails and Notifications

Would you like to be notified when somebody responds to this post? 

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):