I have use case in JMeter JSR223 where I want to fetch First three characters from a String Example given Below def randomPrefix = org.apache.commons.lang3.RandomStringUtils.randomAlphabetic(6)
vars.put("Trailer_ID", TrailerId)
Output: Trailer_ID : QlWBvp
I want to fetch only QlW
How about String.take() function
def foo = vars.get('Trailer_ID').take(3)
Demo:
More information on Groovy scripting in JMeter: Apache Groovy: What Is Groovy Used For?