Results 1 to 2 of 2

Conditional Expressions

This is a discussion on Conditional Expressions within the Programming forums, part of the Web Designing & Development category; ...

  1. #1
    Senior Member chinmay.sahoo's Avatar
    Join Date
    Dec 2013
    Location
    Banglore
    Posts
    266

    Thumbs up Conditional Expressions

    A conditional expression is like an if statement in a regular expression. The general form is:

    Code:
    (?(condition)yespattern)
    (?(condition)yespattern|nopattern)
    If the assertion succeeds, the regular expression engine matches the yespattern. With the second form, if the assertion doesn’t succeed, the regular expression engine skips the yespattern and tries to match the nopattern.

    The assertion can be one of two types: either a backreference, or a lookahead or lookbehind match. To reference a previously matched substring, the assertion is a number from 1–99 (the most backreferences available). The condition uses the pattern in the assertion only if the backreference was matched. If the assertion is not a backreference, it must be a positive or negative lookahead or lookbehind assertion.

  2. #2
    Senior Member charlottegracie's Avatar
    Join Date
    Jan 2017
    Posts
    207

    Default Re: Conditional Expressions

    Code:
    conditional-expression:
    logical-OR-expression
    logical-OR expression ? expression : conditional-expression
    The logical-OR-expression must have integral, floating, or pointer type. It is evaluated in terms of its equivalence to 0. A sequence point follows logical-OR-expression. Evaluation of the operands proceeds as follows:

    • If logical-OR-expression is not equal to 0, expression is evaluated. The result of evaluating the expression is given by the nonterminal expression. (This means expression is evaluated only if logical-OR-expression is true.)
    • If logical-OR-expression equals 0, conditional-expression is evaluated. The result of the expression is the value of conditional-expression. (This means conditional-expression is evaluated only if logical-OR-expression is false.)

Tags for this Thread