I need to extract an ID from the response of an API call in JMeter. The response looks something like this:

"sessionId":"Edhgjhsbdjkkmsdsd-dlkmsdl.Mkhsdiufhskjndjsbsbd.iusdhfjsnkdnsd" I only need to extract the last string between . and " i.e. iusdhfjsnkdnsd.

I've tried writing this regular expression:

"sessionId":"(.+?).(.+?).(.+?)" I've set the template value to $3$ so only the third value is picked but it doesn't work. Nothing is captured using this regex. Please help me.

  • Hi tejebog328, highly recommend stackoverflow.com as another place for seeking answers to jmeter or regular expressions questions.
    – dank8
    Nov 4, 2022 at 5:44

2 Answers 2


You're almost there, all you need to do is to escape dots with backslashes like:


because dot is a meta-character which means "any character" and if you want JMeter's regex engine to treat is as a dot - you need to escape it properly.

Also you can consider using Boundary Extractor, all you need to do is to set "left" and "right" boundaries and JMeter will capture everything in-between


Dimitri T correctly pointed out the dot has a special meaning

Try to minimise use of the .+ pattern, some suggestions: regexr.com explains

> const cookieItem = '"sessionId":"Edhgjhsbdjkkmsdsd-dlkmsdl.Mkhsdiufhskjndjsbsbd.iusdhfjsnkdnsd"'
> console.log( cookieItem.match(/\w+/g).at([-1])

here are some equivalents:
console.log(cookieItem.match(/(?<=[.-])\w+(?=")/g).at(-1) ); returns the last segment. console.log(cookieItem.match(/\w+(?="$)/gm).at(-1) ); anchors to the end of the string.

The Mozilla JavaScript reference for .match(str, pattern)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.