Larry Steinle

February 9, 2011

Use Regular Expressions to Clean SQL Statements

Filed under: RegEx,SQL Server — Larry Steinle @ 9:00 pm
Tags: ,
When writing programs that use inline SQL statements I prefer to format the sql statements for readability with solid comments in the sql statement. Sometimes the formatting or comments gets in the way during processing and must be removed. In this article I will demonstrate how to remove formatting and comments from a SQL Statement using Regular Expressions.
(more…)
Advertisements

January 30, 2011

String.Split On Steroids

Filed under: RegEx,VS.Net — Larry Steinle @ 9:25 am
Tags: , , , , ,

The String.Split function uses a separator to divide a string value into an array of string values. Unfortunately the split function does not support text qualifiers. As a result, if the separator is contained within a text qualified block of characters, the text block gets split.

In this article we will create a new extension called, FullSplit, that will implement the same basic functionality of the String.Split function with the added support of text qualifiers and assignment operators. When assignment operators are used the return value will be of type StringDictionary where the left side of the operator represents the DictionaryEntry.Key property and the right side represents the DictionaryEntry.Value property.

Finally we will conclude the article by updating the code from a previous post, Extending IEnumerable, to support dictionary entries by separating the key/value pair with an operator.

(more…)

Create a free website or blog at WordPress.com.