Forum Discussion
Sam_D_
Oct 11, 2019Altostratus
iRules uses regsub to do URL conversions
I'd like to automatically convert URLs, i.e
- "https://sc-uat.ct.example.com/sc/" into "https://invbeta.example.com/sc/"
- "https://sc-dev.ct.example.com/sc/" into "https://invtest.example.com/sc/"
- "https://sc-qa.ct.example.com/sc/" into "https://invdemo.example.com/sc/"
I've tried following code snippet in TCL
set loc "https://sc-uat.ct.example.com/sc/"
set envs(dev) "test"
set envs(uat) "beta"
set envs(qa) "demo"
puts $envs(uat)
regsub -nocase {://.+-(.+).ct.example.com} $loc {://inv[$envs(\1)].example.com} hostname
puts "new location = $hostname"
But the result is: new location = https://inv[$envs(uat)].example.com/sc/ It seems that [$envs(uat)] is NOT eval-ed further.
Any hints will be appreciated. Thanks in advance
- Sam_D_Altostratus
I've got a very nice answer from https://stackoverflow.com/questions/58338105/tcl-regsub-uses-regex-match-as-index-in-associate-array
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