Using regex OR as a value for a custom variable

Hello,

I’m trying to create a custom variable that has values that contains some regex expression (e.g. ua|uat, int|prer) that will be used as the regex filter in another variable

example:
Let’s say I have a variable like

  • Name : _type
  • “Values seperated by comma” : uat|ua, int|prer

and another variable like

  • Name : _env
  • Query : (returns a list of environments)
  • Regex : /$_type$/

the regex, does not seem to filter the query results properly when “uat|ua” is selected. However, if I replace $_type with /uat|ua/ in the Regex textbox, it works.

Note: I’m trying to filter the queried list for values that end in UAT or UA, etc…

Any ideas?

Thanks

2 Likes

have you found a work around for your issue?

Hi, I have the same problem. Did anybody found a solution?

The regex should look like:

/(${_type:raw})$/

The brackets could be inside the the custom variable value as well, “All” value probably should be .*

An alternative is to use a variable with multiple selection, e.g

$_type custom values:

Var1 : uat, Var2 : ua, Var3 : int, Var4 : prer

Query:

/$_type$/

Select Var1 and Var2 and the query would be resolved to:

/{uat,ua}$/

For one-letter multiple variants one could use:

$_type custom values:

Var1 : at, Var2 : rq

Query:

/[$_type]$/

which would match “rat” and “plant” with Var1 selected, but that wouldn’t work for the original problem without renaming things in data.