Forum Discussion

fuhi_30959's avatar
fuhi_30959
Icon for Nimbostratus rankNimbostratus
Feb 04, 2014

iRule - escape period in Double Quotes,Braces

I hope your help. I want to know to escape period in Double Quotes. I'm trying to write irule. But I can't understand to escape period in Double Quotes.

 

If HTTP request is "http://test.co.jp/aahtmlaa" , in iRule1 the request goes to pool_A, in iRule2 the request goes to pool_B.

 

If HTTP request is "http://test.co.jp/aa.htmlaa" , in iRule1 the request goes to pool_A, in iRule2 the request goes to pool_A.

 

Escape period doesn't effect in iRule1. iRule1 and iRule2 differ in Delimiters.iRule1 uses "".iRule2 uses {}.

 

I read this article. https://devcentral.f5.com/articles/irules-optimization-101-04-delimiters-braces-brackets-quotes-and-more.Uu7qIKLWyzk I want to know to escape period in Double Quotes ,not Braces. Please help.

 

iRule 1.if { [HTTP::uri] matches_regex "\.(htm|html|css|js|png|gif|json|jpg|jpeg)"} { set Pool_Name pool_A } else { set Pool_Name pool_B }

 

iRule2.if { [HTTP::uri] matches_regex {\.(htm|html|css|js|png|gif|json|jpg|jpeg)}} { set Pool_Name pool_A } else { set Pool_Name pool_B }

 

Thanks!

 

3 Replies

  • John_Alam_45640's avatar
    John_Alam_45640
    Historic F5 Account

    Try this:

    This evaluates to true  
    when RULE_INIT {  
        if { "aa.html" matches_regex "aa\\.html" } { log local0. "true" } else { log local0. "false" }  
    }
    
    This evaluates to false:
    when RULE_INIT {
        if { "aahtml" matches_regex "aa\\.html" } { log local0. "true" } else { log local0. "false" }
    } 
    
    This also evaluates to false:
    when RULE_INIT {
    if { "aa-html" matches_regex "aa\\.html" } { log local0. "true" } else { log local0. "false" }
    }