In order to capture the host variable only, you have to create a capture group using parentheses in your regex and then extract the host variable using the group number. Here's an example on how you would do it:
$host {
capture(/(\w+)\..*/) {
$hostvar = $1
}
}
log($hostvar)
This should log the host variable to the console. Notice how the regex in the parameter for the capture contains parenthesis around the first section, which is subsequently split by an explicit period, and then we match the rest of the string, but outside the capture group. Once we're within the scope of the capture, we can extract the capture group by using the $1
variable.