This is a discussion on Regular expression within the C# Programming forums, part of the Software Development category; Hi, We all know about the Regular expression and its uses and how it is used in our code.Here,...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi, We all know about the Regular expression and its uses and how it is used in our code.Here,I want all of you guys to share your knowledge of Regular expression.Thanks to all who shares their knowledge and their expertise here.
__________________ Sathish Kumar.R ![]() Knowledge is meant to SHARE |
| Sponsored Links |
| |||
| Hi, A regular expression is a string that is used to describe or match a set of strings, according to certain syntax rules. Regular expressions are used by many text editors, utilities, and programming languages to search and manipulate text based on patterns.
__________________ Sathish Kumar.R ![]() Knowledge is meant to SHARE |
| |||
| A regular expression, often called a pattern, is an expression that describes a set of strings. They are usually used to give a concise description of a set, without having to list all elements. For example, the set containing the three strings "Handel", "Händel", and "Haendel" can be described by the pattern H(ä|ae?)ndel (or alternatively, it is said that the pattern matches each of the three strings). In most formalisms, if there is any regex that matches a particular set then there is an infinite number of such expressions. |
| |||
| Hi Deeban, You must include the System.Text.RegularExpression classes inorder to perform the process of matching and replacing string with the help of regular expressions.
__________________ Sathish Kumar.R ![]() Knowledge is meant to SHARE |
| |||
| Hi Deeban, The most formalisms consists of Alternation A vertical bar separates alternatives. For example, gray|grey can match "gray" or "grey". Grouping Parentheses are used to define the scope and precedence of the operators (among other uses). For example, gray|grey and gr(a|e)y are equivalent patterns which both describe the set containing "gray" and "grey". Quantification A quantifier after a token (such as a character) or group specifies how often that preceding element is allowed to occur. The most common quantifiers are ?, *, and +. ? The question mark indicates there is zero or one of the preceding element. For example, colou?r matches both "color" and "colour". * The asterisk indicates there are zero or more of the preceding element. For example, ab*c matches "ac", "abc", "abbc", "abbbc", and so on. + The plus sign indicates that there is one or more of the preceding element. For example, ab+c matches "abc", "abbc", "abbbc", and so on, but not "ac".
__________________ Sathish Kumar.R ![]() Knowledge is meant to SHARE |
| |||
| Hi, In the formal theory,Regular expressions can be expressed in terms of formal language theory. Regular expressions consist of constants and operators that denote sets of strings and operations over these sets, respectively. Given a finite alphabet Σ the following constants are defined: (empty set) ∅ denoting the set ∅ (empty string) ε denoting the set {ε} (literal character) a in Σ denoting the set {a} |
| |||
| Hi Deeban, Also there are some operations in the regular expressions.They are Concatenation: (concatenation) RS denoting the set { αβ | α in R and β in S }. For example {"ab", "c"}{"d", "ef"} = {"abd", "abef", "cd", "cef"}. Alteration: (alternation) R|S denoting the set union of R and S. Kleene Star: (Kleene star) R* denoting the smallest superset of R that contains ε and is closed under string concatenation. This is the set of all strings that can be made by concatenating zero or more strings in R. For example, {"ab", "c"}* = {ε, "ab", "c", "abab", "abc", "cab", "cc", "ababab", ... }.
__________________ Sathish Kumar.R ![]() Knowledge is meant to SHARE |
| |||
| Hi deeban, Sure.I can give you the examples for the operations to you.Here are some examples a|b* denotes {ε, a, b, bb, bbb, ...} (a|b)* denotes the set of all strings consisting of any number of a and b symbols, including the empty string ab*(c|ε) denotes the set of strings starting with a, then zero or more bs and finally optionally a c.
__________________ Sathish Kumar.R ![]() Knowledge is meant to SHARE |
| |||
| Hi Deeban, The regexp classes are contained in the System.Text.RegularExpressions.dll assembly, and you will have to reference this assembly .
__________________ Sathish Kumar.R ![]() Knowledge is meant to SHARE |
| |||
| Hi Deeban, Yes.We can include the dll at compile time by using the follwing code csc /r:System.Text.RegularExpressions.dll foo.cs will build the foo.exe assembly, with a reference to the System.Text.RegularExpressions assembly.
__________________ Sathish Kumar.R ![]() Knowledge is meant to SHARE |
| |||
| Hi Deeban, There are actually only six classes and one delegate definition in the assembly namespace. These are: 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
__________________ Sathish Kumar.R ![]() Knowledge is meant to SHARE |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| what is regular expression? | saravanan | PHP Programming | 8 | 03-28-2008 06:12 AM |
| How to use Regular expression in Java? | S.Vinothkumar | Java Programming | 3 | 11-28-2007 08:45 PM |
| Regular expression tips & tricks | prasath | Database Support | 8 | 09-24-2007 09:55 PM |
| Can any one give regular expression for this string? | raj | PHP Programming | 1 | 07-24-2007 11:42 PM |
| Regular expression | vadivelanvaidyanathan | Perl | 0 | 07-15-2007 06:21 PM |