declare local var.input STRING;

set var.input = "/foo///bar//baz";
log "syslog " + req.service_id + " loggerName :: " +
    "Replace multiple //// in URL paths with a single one: "
    var.input + " => " +
    regsuball(var.input, "/+", "/");

set var.input = "www.example.com";
log "syslog " + req.service_id + " loggerName :: " +
    "Remove leading www. from host header: " +
    var.input + " => " +
    regsub(var.input, "^www\.","");

set var.input = "/foo/bar/";
log "syslog " + req.service_id + " loggerName :: " +
    "Remove trailing slash: " +
    var.input + " => " +
    regsub(var.input, "/$","");

set var.input = "/products/furbles/12345/photos";
log "syslog " + req.service_id + " loggerName :: " +
    "Map path parameters: " +
    var.input + " => " +
    regsub(var.input, "^/products/(\w+)/(\d+)(/(\w+))?$","/legacy.cgi?cat=\1&id=\2&page=\4");

# Top tip: Don't use regsub for extraction.  If you want to extract
# a value from a header or other VCL variable, use regular expression
# capture groups, like this:
#
# set var.x = if (req.url ~ "foo=(\d+)", re.group.1, "default");

error 601;