Forum Discussion

netadmindetail_'s avatar
netadmindetail_
Icon for Nimbostratus rankNimbostratus
Apr 22, 2015
Solved

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...
  • Sheigh_65772's avatar
    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