Tutorials Forums
     Tutorials Videos
        Sign Up Now For FREE
Welcome, Guest
Username Password: Remember me

Regular Expressions (Quantifiers and Delegates)
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Regular Expressions (Quantifiers and Delegates)

Regular Expressions (Quantifiers and Delegates) 12 Jan 2010 03:49 #212

In this tutorial you will learn about Quantifiers, Grouping constructs, Backreferences, Backreference Constructs, Alternation Constructs, Miscellaneous Constructs, System.Text.RegularExpressions Namespace, Delegates in the namespace System.Text.RegularExpressions and Typical Examples of Regular Expressions.

Quantifiers
Quantifiers add optional quantity data to a regular expression. A quantifier expression applies to the character, group, or character class that immediately precedes it.

Grouping constructs:
These allow you to capture groups of subexpressions and to increase the efficiency of regular expressions

Backreferences provide a convenient way to find repeating groups of characters. They can be thought of as a shorthand instruction to match the same string again.

Backreference Constructs

These are optional parameters that add backreference modifiers to a regular expression



Alternation Constructs
These modify the regular expression to allow either/or matching



Miscellaneous Constructs
These are sub-expressions that modify a regular expression


System.Text.RegularExpressions Namespace:
The .NET Base Class Libraries include a namespace and a set of classes for utilizing the power of regular expressions The regexp classes are contained in the System.Text.RegularExpressions.dll assembly, and you will have to reference the assembly at compile time in order to build your application.

The namespace System.Text.RegularExpressions defines the following classes

Capture: Contains the results of a single match
CaptureCollection: A sequence of Capture's
Group: The result of a single group capture, inherits from Capture
Match: The result of a single expression match, inherits from Group
MatchCollection: A sequence of Match's
MatchEvaluator: A delegate for use during replacement operations
Regex: An instance of a compiled regular expression

Regex class also contains several static methods:


Escape: Escapes regex metacharacters within a string
IsMatch: Methods return a boolean result if the supplied regular expression matches within the string Match: Methods return Match instance
Matches: Methods return a list of Match as a collection
Replace: Methods that replace the matched regular expressions with replacement strings
Split: Methods return an array of strings determined by the expression
Unescape: Unescapes any escaped characters within a string

Delegates in the namespace System.Text.RegularExpressions

MatchEvaluator: The delegate that is called each time a regular expression match is found during a Replace operation.

Enumerations in the namespace System.Text.RegularExpressions

Regexoptions:
Provides enumerated values to use to set regular expression options.

Download sample below This attachment is hidden for guests. Please log in or register to see it.
Attachments:
  • Attachment This attachment is hidden for guests. Please log in or register to see it.
  • CE
  • OFFLINE
  • Administrator
  • Posts: 197
  • Karma: 78
CodersEngine
  • Page:
  • 1
Moderators: mnjon
Time to create page: 0.20 seconds