I have variable as string in this view:
["564546","56454654","3123123","868987"]
I need the script that deletes unnecessary symbols [ ] "
and put it to another variable . (something like trim
method)
I assume it should be made in BeanShell pre-processor.
It can be done via Beanshell PreProcessor as follows:
Put the following code into the PreProcessor's "Script" area:
String yourvar = vars.get("yourvar");
String anothervar = yourvar.replace("[","").replace("]","").replaceAll("\\\"","");
vars.put("anothervar",anothervar);
Change "yourvar" and "anothervar" according to your variables reference names.
yourvar
- source variable nameanothervar
- result variable name vars
is a shorthand to JMeterVariables class instance which provides access to JMeter variables in current context. See JavaDoc for the class for all available methods and How to use BeanShell: JMeter's favorite built-in component guide for advanced information on Beanshell scripting in JMeter.