Forum Discussion
Darren_21048
Nimbostratus
Jun 15, 2011Regex 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 followin...
Darren_21048
Nimbostratus
Jun 15, 2011Hi Colin,
Thanks for getting back to me, Here is the iRule as it stands at present and it's the only iRule on my test VIP. It seems to work if I have an end marker that in the html output is quite near the first regex, so for example having my last match as a .+> seems to work as I hit that fairly quickly (hence my theory that line feeds / carriage returns are what's giving me difficulty).
when HTTP_RESPONSE {
HTTP::header remove server
foreach header {Server Date X-Powered-By} {
while { [HTTP::header exists $header] } {
log local0. "Removing- $header: [HTTP::header value $header]"
HTTP::header remove $header
}
}
Disable the stream filter by default
STREAM::disable
Check if response type is text
if {[HTTP::header value Content-Type] contains "text"}{
Match any http:// instance and replace it with nothing
STREAM::expression {@
.*>@} - This doesn't break the page
STREAM::expression {@comments.start.here.+comments.end.here@}
STREAM::expression {@comments.start.here.*comments.end.here@}
Enable the stream filter for this response only
STREAM::enable
}
}
when STREAM_MATCHED {
log local0. "matched: [STREAM::match]"
STREAM::replace "[string map {[^A-Za-z][bB][uU][sS][^A-Za-z] *******} [STREAM::match]]"
STREAM::replace "[string map {helloooooooo XXXXXXXXXXX} [STREAM::match]]"
}
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects