views:

510

answers:

3

Greetings,

In Jmeter's regex component, I am running into an issue when the expression has both a variable AND a literal '$'. It always returns as fail. When I replace the variable with a hardcoded value, it works fine. I have verified the variable is returning the expected value in previous call.

Failed Expression: (variable and literal '$')

<option value="${variable}".+?>\$(.+?)</option>

Working Version: (no variable)

<option value="1".+?>\$(.+?)</option>

Alternately, if I remove the literal '$', it works.

Alt. Working Expression: (variable, no literal '$')

<option value="${variable}".+?>(.+?)</option>

Thoughts?

A: 

You could do it using a BeanShell function, which has access to the "vars" object.

For example, vars.get("variable") is equivalent to ${variable}.

Link 1 <-- Search for Bean on the page

Phill Pafford
Thanks for the idea - unfortunatley, I'm running into the same problem. I understand the syntax to be: <option value="${__BeanShell(vars.get("variable"))}".+?>\$(.+?)</option>To call the function, it leads with '${' which seems to be troublesome.Source:http://jakarta.apache.org/jmeter/usermanual/functions.html#__BeanShell
BlackGaff
+1  A: 

Work around has been to replace \$ with \W or \S

BlackGaff
A: 

You could try [$] as an alternative to escaping it with a backslash.

wombleton