09.11.2012

Replace function for JMeter

Here is code where implemented function which can be used for replace in string some pattern.
Of course for it can be used BeanShel scripting or something like that, but precompiled function works much faster and resource saving.
Compile ReplaceSJP.java or use precompiled somePlugins.jar
Examples for using:


Example >
Result

${__Replace(some_xml_big_data_with_#CustomerID#_and_another_else,#CustomerID#,3.15-9.20)} > 
some_xml_big_data_with_3.15-9.20_and_another_else

${__Replace(some_#FormatID#_big_data_with_#CustomerID#_and_another_else,#CustomerID#,3.15-9.20,#FormatID#,xml)} >
some_xml_big_data_with_3.15-9.20_and_another_else

${__Replace(123456,5,7,3,9)} >
129476

${__Replace(123456,[1-2],7,3,9)} >
779456

${__Replace(123456789qwerty,[1-2],7,3,9,[w],word)} >
779456789qworderty

in User defined variables                                                                            
string=123456789qwerty
${__Replace(${string},[1-2],7,3,9,[w],word)} >
779456789qworderty