Parse node name from url with iRule

Hi,

I am new to the F5 world and loving the new learning experience. Can someone help with the below?

I have a VIP that will front several dev machines that have multiple websites on them with the servername (node name) in the url. I am trying to find the best approach to create an iRule that sets a variable that has the parsed servername (node name) from the url and then send it to the appropriate node.

Sample url: https://MSxxxxx-help-sp.domain.net https://MSxxxxx-hello-sp.domain.net

I want to parse the MSxxxxx out of the url and have that set as the node that it should go to.

Any help would be most appreciated.

Thanks,

Daryl

e.g.

config

root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
ltm virtual bar {
    destination 172.28.24.10:80
    ip-protocol tcp
    mask 255.255.255.255
    profiles {
        http { }
        tcp { }
    }
    rules {
        qux
    }
    source 0.0.0.0/0
    source-address-translation {
        type automap
    }
    vs-index 46
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm data-group internal host-to-node
ltm data-group internal host-to-node {
    records {
        MSxxxxx {
            data 200.200.200.101:80
        }
    }
    type string
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux
ltm rule qux {
    when HTTP_REQUEST {
  log local0. "host=[HTTP::host] uri=[HTTP::uri]"
  if { [scan [HTTP::host] {%[^-]} ht] == 1 } {
    log local0. "ht=$ht"
    set nd [split [class match -value $ht equals host-to-node] :]
    log local0. "nd=$nd"
    node [lindex $nd 0] [lindex $nd 1]
    log local0. "cmd=node [lindex $nd 0] [lindex $nd 1]"
  }
}
}

 /var/log/ltm

[root@ve11a:Active:In Sync] config  tail -f /var/log/ltm
Jul  2 19:27:13 ve11a info tmm[29362]: Rule /Common/qux : host=MSxxxxx-help-sp.domain.net uri=/something
Jul  2 19:27:13 ve11a info tmm[29362]: Rule /Common/qux : ht=MSxxxxx
Jul  2 19:27:13 ve11a info tmm[29362]: Rule /Common/qux : nd=200.200.200.101 80
Jul  2 19:27:13 ve11a info tmm[29362]: Rule /Common/qux : cmd=node 200.200.200.101 80