Hi Gavin,
Your scan pattern of %*[^/]/%[^_] would not work because all virtual server names in 11.x will start with a /. I don't think you can use scan alone to match a variable number of subfolders.
Also, with scan, you can check the number of matches before trying to use one of the match variables:
if {[scan $virtualname {%*[^/]/%[^_]} vname] == 1}{
log local0. "Matched $vname from $virtualname"
} else {
log local0. "Couldn't parse $virtualname"
}
Here are three ways to do it. The string commands are more complicated but also more efficient than the single regexp. I'd guess the second option is most efficient, but you could use timing to test this:
http://devcentral.f5.com/wiki/iRules.timing.ashx
scan [string range [virtual name] [expr {[string last / [virtual name]] +1}] end] {%[^_]%*s} vs_name
log "scan: $vs_name"
set vs_name [findstr [string range [virtual name] [string last / [virtual name]] end] "/" 1 "_"]
log "findstr: $vs_name"
regexp {(/.*/)?[^_]+} [virtual name] unused unused vs_name
log "regexp: $vs_name"
Aaron