Named text and value capture groups variable

Hi all,

I have a problem to understand the correct usage of named text and value capture groups for variables.

I have a set of data like this “hostname.domain.net|192.168.0.1” where I’d like to have a dropdown box for the user to select the host and use the corresponding ip address in other charts. As you can see the two information are separated by ‘|’.

In order to separate the different information stored in this string I have created a regex

/(?<text>.*)\||\|(?<value>.*)/g

This shows only the hostname in the dropdown box.

How can I use the value (IP-Address / <value>) after the user has selected the hostname? Will the selection in the dropdown box create a new variable I can use in other charts or how can I access the value field.

thanks
horst

OK, solved. It was, as expected, the regex.

Correct regex would be:/(?<text>.*)\|(?<value>.*)/gm

1 Like

Thanks for the help!

Just in case anyone else comes across this, if you change the data to output in the format specified here and use the regex, the variables page will ONLY show the “text” field in the “preview of values” at the bottom of the variables page. Once you go back to use the variable in your visualization, you just call it as normal (i.e. - ($HostName) ) in your query but it will send the “value”, not the “text” - you do not need to do anything special to call the “value” specifically.