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.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
Maybe I'm missing what your trying to do.
Here's another scan example:
% scan $string {%*[^:]://%[^:]} fqdn
1
% puts $fqdn
sub.domain.com
This will exclude everything up until '://' which it will also throw out. From there it will match the remaining string until the next instance of ':' is found and put that into the fqdn variable.
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