Forum Discussion
Phil_Dindak
Nimbostratus
Mar 28, 2018Regex alternative suggestion for string replacement
I have a couple of regexes that work just fine.
log local0. "original [HTTP::uri]"
if { [HTTP::uri] matches_regex {/lpportal-\d+/?} } {
regsub -- {/lpportal-\d+/?} [HTTP::uri] $portal p1
HTTP::uri $p1
log local0. "replaced [HTTP::uri]"
}
The regexes mean: /lpportal-\d+/? = look for “/lpportal-“ followed by at least one or more digits (\d+) and possibly a trailing “/” (/?)
However, I read here that regexes are one of the most expensive calls to make on the BIG-IP LTM. Look for alternative that is not so cpu expensive.
Thanks in advance!
Phil
- jaikumar_f5
Noctilucent
You can opt the "switch -glob" and "string match" rather than going with matches_regex. As you already know regex do takes high CPU.
iRules 101 - 10 - Regular Expressions
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