Anthony_Vaz_547
Jul 07, 2009Nimbostratus
Stream::expression irule problem
Hi guys
I'm sure this is just me being an airhead but I can't get this irule to work. Any input greatly appreciated
We have a need to rewrite the content of a HTTP response. I am searching for what I want to find (which is "top.") and replacing it (with "top.child1.")
This is the irule code for the above (and this works).
When HTTP_RESPONSE {
Disable the stream filter by default
STREAM::disable
Check if response type is text
if {[HTTP::header value Content-Type] contains "text"}{
Replace any "top. instance with self.
STREAM::expression "@top\.@top.child1.@"
Enable the stream filter for this response only
STREAM::enable
}
}
However, annoyingly, there are occassions when "top." is too generic. There are a number of IMG SRC tags that end in top.jpg. Therefore, those image tags are being rewritten to top.child1.jpg.
I would like to have an "unless" stream expression. The STREAM::expression wiki page suggests that this can be done (http://devcentral.f5.com/wiki/default.aspx/iRules/stream__expression)
I have therefore modified my STREAM::expression to be
STREAM::expression {@top\.(?!jpg)@top.child1.@}
I infer, from the Wiki page, that this expression should always rewrite top. to top.child1. unless the original string is top.jpg
However this doesn't work - Can anyone help me out with what the correct syntax should be?
Many thanks in advance