Forum Discussion

Darren_21048's avatar
Darren_21048
Icon for Nimbostratus rankNimbostratus
Jun 15, 2011

Regex in STREAM::expression

I am looking to implement a regex within STREAM::expression to find the User Comments section on our web pages which we mark with a specific begin and end comment in the HTML. I am using the following within the iRule (with the usual Stream::disable / enable etc. which I've stripped out here for readability) which in theory should perform a string replacement within that section of the web page.

 

 

STREAM::expression {@sectionbegin.+sectionend@}

 

 

 

when STREAM_MATCHED {

 

log local0. "matched: [STREAM::match]"

 

STREAM::replace "[string map {[^A-Za-z][fF][iI][nN][dD][^A-Za-z] *******} [STREAM::match]]"

 

}

 

 

 

 

The difficulty I'm having is getting the regex in STREAM::expression to match over line feeds / carriage returns. I've tried [.\r\n]+, [\s\s]+ and various others without success. I can get the match to work in part if I miss out sectionend from my example but do not match on a line feed.

 

 

 

Any suggestions or the correct regex for this would be most appreciated.

 

 

 

Thanks

 

 

 

Darren C

 

11 Replies

  • FYI, I hit this issue recently. I'm not sure I fully understand what a partial match is but regardless, I doubled the value of the buffer, within the HTTP_RESPONSE event:

    when HTTP_RESPONSE {
      STREAM::max_matchsize 8192
      STREAM::enable
      ...
    }
    

    Note, the actual response payload that was giving me issues was around 64kB. Considering the issue was intermittent, it's possible the buffer relates to all traffic handled by the Virtual Server, not each connection.

    Using the STREAM::max_matchsize command in the STREAM_MATCHED event (as I'd seen suggested elsewhere) doesn't work.