Forum Discussion
netadmindetail_
Apr 22, 2015Nimbostratus
Better way to Cleaning UP string variable
Hi all
I must use the destination FQND of a TCP connection. I'm able to collect the TCP payload but I need to compare it with a data-class. But before doing that I need to clean the TCP payloa...
- 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.com
Check 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
Sheigh_65772
Cirrus
Quick time comparison of the two:
% time { set fqdn [string range $string [expr [string first "://" $string] + 3] [expr [string last ":" $string] - 1]] } 10000
5.7755 microseconds per iteration
% time { scan $string {%*[^:]://%[^:]} fqdn } 10000
1.2681 microseconds per iteration
netadmindetail_
Apr 22, 2015Nimbostratus
Wow, thank you very much for this kind of output. Can you tell me how you've been able to grab this information ?
Is this the time keyword ? how do you stop the timer ?
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