Forum Discussion

Josh_Wu_12472's avatar
Josh_Wu_12472
Icon for Nimbostratus rankNimbostratus
Jul 02, 2007

syntax issue on 4.x to 9.x conversion

Hey guys. I've been doing some code conversion to a newer F5 box and ran into a compiling issue with a short code segment from the original.

 

 

----------------------------------------------------------------------------------

 

The original looks like:

 

 

if (http_uri matches_regex "/invoke/FxPartnerDriverStandard.Public[\:,\/]ProcessRqst" and http_header("SSLClientCertStatus") == "NoClientCert") {

 

use pool TMP_PROD_client_Auth_me_6555_pool

 

}

 

 

I've converted it to:

 

 

if {$uri matches_regex "/invoke/FxPartnerDriverStandard.Public[\:,\/]ProcessRqst" and $header == "NoClientCert"} {

 

pool TMP_PROD_client_Auth_me_6555_pool

 

}

 

 

Here's the problem.

 

[\:,\/] is the segment that won't compile. Just FYI, that code segments expanded basically means

 

 

$uri matches_regex "/invoke/FxPartnerDriverStandard.Public: ProcessRqst" (I made the space on purpose since it converts to a smiley if put together...)

 

or

 

$uri matches_regex "/invoke/FxPartnerDriverStandard.Public/ProcessRqst"

 

 

----------------------------------------------------------------------------------

 

 

I have solved the issue by doing an 'or' and just separated the two compares in the if statement. While that's fine, the code becomes long and ugly if we were to add additional symbols. Is there a similar way to do this comparison in 9.x iRule?

 

 

Thanks!!
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    You should be able to use the standard TCL "or" structure in the regex comparison. It would look like:

     

     

    
    if {$uri matches_regex "/invoke/FxPartnerDriverStandard.Public(\:|\/)ProcessRqst" and $header == "NoClientCert"} {
      pool TMP_PROD_client_Auth_me_6555_pool
    }

     

     

    The code change in question is (\:|\/). This represents a match for two possible branches, and will match either of them.

     

     

    There's decent documentation on TCL's regex matching here on sourceforge: Click here. Look for the the second paragraph of the "REGULAR EXPRESSION SYNTAX" section for the description of the "|" operator in matching multiple strings.

     

     

    HTH,

     

    Colin

     

     

     

  • I wasn't sure where to look for to get my answers so thanks a lot for the reply! Helped a lot in clarifying some syntax changes in 9.x