jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: More on RegEx and BeanShell function
Date Wed, 02 Aug 2006 16:06:53 GMT
On 02/08/06, amelaao <amelaao@gmail.com> wrote:
>  I think my problem comes from the way I'm referencing this variable created
> by RegEx from BeanShell.

Yes, see below.

> My RegEx look like:
>
> ReferenceName:       Attributes
> Regular Expression: <ProductAttributes>(.+?)</ProductAttributes>
> Template:                $1$
> Match No:               1
>
> and the BeanShell function string:
>
> ${__BeanShell(String str=vars.get("${Attributes}"); String newstr =
> str.replace("<"\,"<p:"); return newstr;, )} .
>

${Attributes} will be replaced by the contents of the variable; you
are then looking this up as a variable, which won't exist.

Try

${__BeanShell(${Attributes}.replace("<"\,"<p:"))}

So long as Attributes does not contain any commas, it should work.

If it does contain a comma, try:

${__BeanShell(vars.get("Attributes").replace("<"\,"<p:"))}

>
>  I tried many combinations of
>                  vars.get("${Attributes}");
>                 vars.get("${Attributes_g1}");
>                  vars.get("Attributes"); inside this BeanShell but each
> returns null, although the RegExpression variable Attributes displayed
> through a separate JavaRequest Sampler is perfectly valid, not null,
> XML string.

That is because you are de-referencing the variable twice...

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Mime
View raw message