Locating multiple nested If statements using regular expressions

Posted by TERACytE on Stack Overflow See other posts from Stack Overflow or by TERACytE
Published on 2010-05-30T04:05:07Z Indexed on 2010/05/30 4:12 UTC
Read the original article Hit count: 298

Filed under:
|
|
|

Is there a way to search for multiple nested if statements in code using a regular expression?

For example, an expression that would locate an instance of if statements three or more layers deep with different styles (if, if/else, if/elseif/else):

if (...) {
    <code>
    if (...) {
        <code>
        if (...)
            <code>
    } else if (...) {
        <code>
    } else {
        <code>
    }
} else {
    <code>
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about java