Using Regular Expressions Metacharacters with .net – Captures
(exp)
(exp) – Match exp and capture it in an automatically numbered group. Common, unadorned parentheses generally perform two functions, grouping and capturing. Common parentheses are almost always of the form (), but a few flavors use \(\).
(?<name>exp)
(?<name>exp) – Match exp and capture it in a group named name. .NET languages support captures to named locations.
(?:exp)
(?:exp) – Match exp, but do not capture it, but, as the name implies, group regex components for alternation and the application of quantifiers. They are not counted as part of $1, $2, etc. After a match of (1|one)(?:and|or)(2|two), for example, $1 contains ’1′ or ‘one’, while $2 contains ’2′ or ‘two’. Grouping-only parentheses are also called non-capturing parentheses.





Comments
No comments yet.
Leave a comment