Forum Discussion
Better way to Cleaning UP string variable
- Apr 22, 2015
How about using scan?
If the variable string is set '9net.tcp://sub.domain.com:12345/abcdefg' or 'sometotherstuff9net.tcp://sub.domain.com:12345/abcdefg/lkjsdflkj/sdfl' etc then try using
scan $string {%*[^/]//%[^:]} fqdn
this results in a new variable $fqdn of 'sub.domain.com'
You can test it out by using the tclsh
% set string "lkasdflkjwe234239net.tcp://sub.domain.com:12345/abcdefg/sdlfkjasf" lkasdflkjwe234239net.tcp://sub.domain.com:12345/abcdefg/sdlfkjasf % puts $string lkasdflkjwe234239net.tcp://sub.domain.com:12345/abcdefg/sdlfkjasf % scan $string {%*[^/]//%[^:]} fqdn 1 % puts $fqdn sub.domain.comCheck out this link: https://devcentral.f5.com/articles/irules-101-18revisiting-the-tcl-scan-command
FYI I'm just starting to play with scan so YMMV.
Sheigh
Here's what I found.
Tells me if it's optimize or not.
set TCP_Payload [string range [TCP::payload] [expr [string first "://" [TCP::payload]] + 3] [expr [string last ":" [TCP::payload]] - 1]]
I must use an expr cause the string first and string last return only the first index.
Any other suggestion would be appreciated
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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