Tag Archives: linqpad

Regex and LINQPad

Recently, I was working with a customer who needed dynamic worksheet names in their Excel workbooks.  With ExcelWriter this is no problem!  Since the input was coming from the end users, I need to perform some validation on the input to make sure it conforms to Excel’s restrictions on what a valid worksheet name can be.

Valid Worksheet Names in Excel

  1. They cannot exceed 31 characters.
  2. They cannot contain the following characters: \ / ? * [ ]
  3. The name cannot be the same as another Worksheet in the Workbook.
  4. The worksheet name cannot be blank

In this case I am interested in #2 and dealing with invalid characters.  I know that Regex is the best option for this–when I’m working with Regex, I often find testing to be a pain. I‘ll open Visual Studio, create a console application and write some code to test my patterns.  Just when I was starting to get fed up with all these random testing console applications in my projects directory, I remembered an application called LINQPad that my co-work Sean told me about. LINQPad is a standalone C#/VB/F# scratch pad that can instantly execute code. The output is displayed in a rich format.

So I came up with the following Regex Pattern: Continue reading Regex and LINQPad