InternetUnicodeHTMLCSSScalable Vector Graphics (SVG)Extensible Markup Language (xml) ASP.Net TOCASP.NetMiscellaneous FeatureASP.NET ScriptingASP.NET Run-time Object System.Text.RegularExpressionsRegular Expression EngineRegular Expression Result PatternCharacter EscapesCharacter ClassesAnchorsQuantifiersGrouping ConstructsBackreference Constructs Draft for Information Only
ContentRegular Expression
Alternation Constructs
Regular Expression Alternation ConstructsAlternation constructs modify a regular expression to enable either/or or conditional matching. .NET Alternation Constructs.NET supports three alternation constructs:
Pattern Matching with |The vertical bar (|) character can be used to match any one of a series of patterns, where the | character separates each pattern. Like the positive character class, the | character can be used to match any one of a number of single characters. Conditional Matching with an ExpressionThe conditional matching with an expression to match one of two patterns depending on whether it can match an initial pattern. The conditional matching with an expression is of the form, (?( expression ) yes | no ). The parameter expression is the initial pattern to match. The parameter yes is the pattern to match if expression is matched. The parameter no is the optional pattern to match if parameter expression is not matched. The regular expression engine treats expression as a zero-width assertion; that is, the regular expression engine does not advance in the input stream after it evaluates expression. Therefore, this construct is equivalent to (?(?= expression ) yes | no ). The parameter, (?= expression ) is a zero-width assertion construct. Because the rgular expression engine interprets expression as an anchor (a zero-width assertion), expression must either be a zero-width assertion or a subexpression that is also contained in yes. Otherwise, the yes pattern cannot be matched. If expressionis a named or numbered capturing group, the alternation construct is interpreted as a capture test; In other words, the regular expression engine does not attempt to match the captured substring, but instead tests for the presence or absence of the group. Conditional Matching Based on a Valid Captured GroupThe conditional matching based on a valid captured group attempts to match one of two patterns depending on whether it has matched a specified capturing group. The conditional matching based on a valid captured group is of the form (?( name ) yes | no ) or (?( number ) yes | no ). the parameter name is the name and the parameter number is the number of a capturing group. The parameter yes is the expression to match if name or number has a match, and the parameter no is the optional expression to match if it does not. If name does not correspond to the name of a capturing group that is used in the regular expression pattern, the alternation construct is interpreted as an expression test. Typically, this means that expression evaluates to false. If number does not correspond to a numbered capturing group that is used in the regular expression pattern, the regular expression engine throws an ArgumentException. ExamplesExamples of Alternation Constructs
ASP.NET Code Input:
HTML Web Page Embedded Output: See also
Source/Referencee
©sideway ID: 190700031 Last Updated: 7/31/2019 Revision: 0 Ref: ![]() References
![]() Latest Updated Links
![]() ![]() ![]() ![]() ![]() |
![]() Home 5 Business Management HBR 3 Information Recreation Hobbies 8 Culture Chinese 1097 English 339 Travel 18 Reference 79 Computer Hardware 254 Software Application 213 Digitization 37 Latex 52 Manim 205 KB 1 Numeric 19 Programming Web 289 Unicode 504 HTML 66 CSS 65 SVG 46 ASP.NET 270 OS 431 DeskTop 7 Python 72 Knowledge Mathematics Formulas 8 Set 1 Logic 1 Algebra 84 Number Theory 206 Trigonometry 31 Geometry 34 Calculus 67 Engineering Tables 8 Mechanical Rigid Bodies Statics 92 Dynamics 37 Fluid 5 Control Acoustics 19 Natural Sciences Matter 1 Electric 27 Biology 1 |
Copyright © 2000-2025 Sideway . All rights reserved Disclaimers last modified on 06 September 2019