F5 irule Regex Examples
Note that F5 uses TCL as a scripting language, so all these commands do follow TCL syntax.
Matching with regexp
Use this to match a string
regexp {pattern} [HTTP::path] # match HTTP path
regexp {(?i)pattern} [HTTP::path] # same, but case insensitive
rexexp {(pattern)} [HTTP::path] -> resultVar # store match string into result variable
regexp -all {\/} [HTTP::path] # count all slashes
Replacing with regsub
Use this to replace strings
regsub $input + output # Replace first occurences of '%20' in variable input with '+'
regsub -all $input + output # Replace all occurences of '%20' in variable input with '+'
regsub -nocase $input bar output # Case insensitive replace of "foo" with "bar" in variable input
Note how each time you need to dereference the input variable “$input” and just name the output variable “output”.
SSL Certificates
F5 - Lets Encrypt Integration: (https://devcentral.f5.com/articles/lightboard-lessons-automating-ssl-on-big-ip-with-lets-encrypt-21475)