JMeter test plan has 1 user defined variable Message with a value of <Case Number 000808009 Created.>
1 debug sampler with this BeanShell PostProcessor:
``` lang-js
log.info("Strip out case number");
log.info("CaseCreated<${Message}>");
${__split(${Message},MessagePieces," ")};
log.info("MessagePieces_3<${MessagePieces_3}>");
vars.put("CaseNumber", ${MessagePieces_3});
log.info("CaseNumber<${CaseNumber}>");
```
The Debug PostProcessor shows these variables:
Message=Case Number 000808009 Created.
MessagePieces=Case Number 000808009 Created.
MessagePieces_1=Case
MessagePieces_2=Number
MessagePieces_3=000808009
MessagePieces_4=Created.
MessagePieces_n=4
CaseNumber does not appear.
Log shows this:
2022-12-30 15:59:23,580 INFO o.a.j.u.BeanShellTestElement: Strip out case number 2022-12-30 15:59:23,580 INFO o.a.j.u.BeanShellTestElement: CaseCreated<Case Number 000808009 Created.> 2022-12-30 15:59:23,580 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval In file: inline evaluation of: ``log.info("Strip out case number"); log.info("CaseCreated<Case Number 000808009 C . . . '' Encountered "000" at line 3, column 13.
2022-12-30 15:59:23,580 WARN o.a.j.e.BeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval In file: inline evaluation of: ``log.info("Strip out case number"); log.info("CaseCreated<Case Number 000808009 C . . . '' Encountered "000" at line 3, column 13.
I've tried every syntax I could Google to no avail. Any thoughts/suggestions? It seems to get confused with the actual message line as part of the inline evaluation of the beanshell.
I have already found this solution that I can use, but I would prefer to use the split function.
``` lang-js
String line = vars.get("Message");
String[] words = line.split(" ");
for (int i = 0; i < words.length; i++) {
log.info(words[i]);
if (i == 2) {
log.info("Third word is: " + words[2]);
}
}
```