|
|
Regular ExpressionsRegular Expressions, found in the System.Text.RegularExpressions namespace, can be used to parse, extract information from, and modify strings of text. They are a very powerful tool for pattern matching, going far beyond the LIKE statements of VisualBasic or SQL.
Parsing with Regular Expressions - CountOccurrences in a String - 1/9/2004 Regular Expressions are one of the most powerful innovations to debut with Visual Studio .NET. This article shows another parsing method; counting occurrences of an expression in a string. more...
Count Occurences of a Token in a String - 12/16/2003 With the onset of .NET, I quickly began to feel my age. Granted, at 32 I shouldn't be whining about age but here I am. You see, I took my Computer Science classes a few years ago and missed out on a lot. While teaching myself new things has always been something I do pretty well, not everything sticks. And these days, I really wish I would have spent my time learning the in's and out's of regex's instead of learning to prove my table designs with both algebra and calculas.... but I digress. more...
Regex Basics - Simple Pattern Matching with IsMatch - 12/4/2003 Writing code to search for a substring within another string is quite simple. The IndexOf() String function will tell us the exact starting position of the substring in the string or return -1 if it does not appear. Often, this is enough to get us where we want to go. One problem with this approach is that it may require several different calls to cover alternate cases. For instance, what if we need to find not only the string "File" within an input string, but we need to find the word "File" only when not followed by " System" or " Folder". Additionally, we don't care about capitalization - "File", "file", and "FiLe" are all valid. more...
Regex Basics - Input Validation - 11/8/2003 The String.Replace function has been a valuable tool for years, allowing programmers to change strings by replacing a specific substring with another substring. While this is usually enough, the Regex.Replace function goes a step (ok, maybe 10 steps) further. more...
Regex Basics - Named Groups, Backreferences, and Regex.Replace - 11/8/2003 A U.S. Social Security Number is a 9-digit number, but it can be formatted in several different ways. Sometimes it appears as a number with no separation, like 123456789. Other times, however, a space or a dash may by used to make it 123 45 6789 or 123-45-6789. We may write an expression to cover these different separators that looks like this: more...
Using Replacement Strings with Regex.Replace - 11/8/2003 The String.Replace function has been a valuable tool for years, allowing programmers to change strings by replacing a specific substring with another substring. While this is usually enough, the Regex.Replace function goes a step (ok, maybe 10 steps) further. more...
< Previous Page 2 of 2 Next >
|
|