Regular Expression tester - ASP.NET

I've posted code in ColdFusion and JavaScript for a regular expression tester. Since I'm looking at ASP.NET development ... here's one built on ASP.NET (3.5, but it should run fine on 2.0), in C#.


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="RegularExpression.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <title>ASP.NET 3.5 Regular Expression tester</title>
    <style type="text/css">
  form {
  form label, .label_kludge {
   margin:5px 0 0;
  form input, form textarea, form select {
   margin:5px 0 0 10px;
  textarea {
  form br {
 <h1>ASP.NET 3.5 Regular Expression Tester</h1>
    <form id="form1" runat="server">
     <asp:Label ID="lbl_RegularExpression" runat="server" Text="Regular Expression:"
  <asp:TextBox ID="RegularExpression" runat="server" Width="350"></asp:TextBox>
  <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
   ControlToValidate="RegularExpression" Display="Dynamic"
   ErrorMessage="You must enter a regular expression." SetFocusOnError="True">You
  must enter a regular expression.</asp:RequiredFieldValidator>
  <br />
  <asp:Label ID="lbl_TestString" runat="server" Text="Test String:"
     <asp:TextBox ID="TestString" runat="server" Width="350px"></asp:TextBox>
  <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
   ErrorMessage="You must enter a string to test the regular expression against."
  must enter a string to test the regular expression against.</asp:RequiredFieldValidator>
  <br />
  <asp:Label ID="lbl_CaseSensitive" runat="server" Text="Case Sensitive:"
  <asp:CheckBox ID="CaseSensitive" runat="server" />
  <br />
  <br />
  <span class="label_kludge">&nbsp;</span><asp:Button ID="btn_Test"
   runat="server" Text="Test" onclick="btn_Test_Click" />
  <br />
  <asp:Label ID="lbl_Results" runat="server"></asp:Label>
  <br />


using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text.RegularExpressions;

public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e) {
  if (this.IsPostBack) {
   Boolean MatchCheck;
   if (this.CaseSensitive.Checked) {
    MatchCheck = Regex.IsMatch(this.TestString.Text, this.RegularExpression.Text);
   } else {
    MatchCheck = Regex.IsMatch(this.TestString.Text, this.RegularExpression.Text, RegexOptions.IgnoreCase);
   if (MatchCheck) {
    this.lbl_Results.Text = "Result: match found";
   } else {
    this.lbl_Results.Text = "Result: no match found";
 protected void btn_Test_Click(object sender, EventArgs e) { 

See it in action!

Want to see it in action? You can do so on