Google


   


You are here: CodeIdol.com > C# > C# Cookbook, 2nd Edition > Regular Expressions

SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

C# Cookbook, 2nd Edition



Problem: You need to find one or more substrings corresponding to a particular pattern within a string. You need to be able to inform the searching code to return either all matching substrings or only the matching substrings that are unique within ...



Problem: You have a regular expression that contains one or more named groups, such as the following: \\\\(?<TheServer>\w*)\\(?<TheService>\w*)\\ where the named group TheServer will match any server name within a UNC string, an...



Problem: You have constructed a regular expression dynamically, either from your code or based on user input. You need to test the validity of this regular expression's syntax before you actually use it. Solution: Use the VerifyRegEx method sh...



Problem: You need to find the last pattern match in a string, but you do not want the overhead of finding all matches in a string and having to move to the last match in the collection of matches. Solution: using the RegexOptions.RightToLeft o...



Problem: You are given a string in which a complex pattern of characters needs to be replaced with a new string. Solution: Using the Replace instance method on the Regex class allows for easy replacement of text within a string. The overloaded...



Problem: You need to replace character patterns within the target string with a new string. However, in this case, each replacement operation has a unique set of conditions that must be satisfied in order to allow the replacement to occur. Consider,...



Problem: A simple method of tokenizingor breaking up a string into its discrete elements was presented in Recipe 2.6. However, this is not powerful enough to handle all your string-tokenizing needs. You need a tokenizeralso referred to as a lexertha...



Problem: You have a handful of regular expressions to execute as quickly as possible over many different strings. Performance is of the utmost importance. Solution: The best way to do this task is to use compiled regular expressions. However, ...



Problem: You need to count lines of text within a string or within a file. Solution: Use the LineCount method shown in Example 10-8 to read in the entire file and count the number of line feeds. Example 10-8. LineCount method using Syste...



Problem: You have a string or file that contains multiple lines. When a specific character pattern is found on a line, you want to return the entire line, not just the matched text. Solution: Use the StreamReader.ReadLine method to obtain each...



Problem: You need to find a specific occurrence of a match within a string. For example, you want to find the third occurrence of a word or the second occurrence of a social security number. In addition, you may need to find every third occurrence o...



Problem: You need a quick list from which to choose regular expression patterns that match standard items. These standard items could be a social security number, a zip code, a word containing only characters, an alphanumeric word, an email address,...



Problem: You have one or more complex regular expressions that may exist in a file outside of your code. You need a way to place comments within the regular expression itself. These comments will aid others in being able to read and maintain your re...



Problem: You need to build a tool that parses ASP.NET pages in order to extract specific bits of information. This tool could possibly be used to detect whether specific meta tags are being used or if there are any comments that could expose informa...


SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

You are here: CodeIdol.com > C# > C# Cookbook, 2nd Edition > Regular Expressions


ADBRITE ads links
   
Related tags







Popular Categories
Unix books and guides

AJAX popular information
C# language guides
Windows books and cookbooks

.......








Business Key Top Sites

be number one
rate your site




    С 2009 года мы стали переводить структура сайта на различные языки. Сайт теперь будет содержать книги не только на английском языке, но также и на других европейских языках, в том числе и на Русском языке.

    Русский Polski Francais Deutsch
    support sitemap terms

© CodeIdol Labs, 2007 - 2009