Extract value from websocket response

Viewed 20

Im getting this response from a websocket

a["MESSAGE\ndestination:/user/p0000450/queue/bets/place/status\ncontent-type:application/json\nsubscription:/queue/bets/place/status-1\nmessage-id:p0000450-79\ncontent-length:139\n\n{"id":"c00656b318","groupId":"113686950","status":"PLACED","code":"0","message":"BetSlip with No.113686950 has been accepted","context":{}}\u0000"]

I would like to extract the betslip no. Cant seem to generate regex that will extract this? please assist

i am planning to use regex extractor and beanshell postprocessor to save the data to excel for all responses

2 Answers

From the provided info it's hard to figure out all the possible formats of the "betslip number", but try this:

\bBetSlip with No\.\s*(\d+)\b

It captures any number of digits before the "BetSlip with No."-string.

Demo: https://regex101.com/r/NKfVm4/1

The easiest solution would be just going for the Boundary Extractor, all you need to do is to provide "left" and "right" boundaries and JMeter will fetch everything in-between:

So if you give:

  • Left boundary as BetSlip with No.
  • and right boundary as has been accepted

enter image description here

you will get what you're looking for.

If you have to do this using Regular Expression Extractor you can go for something like:

BetSlip with No.(\d+) has been accepted

enter image description here

Where:

  • () - grouping
  • d - matches any digit
  • + - repetition
  • \ - escape of meta character

More information: JMeter Regular Expressions

Related