Solved

JMeter regex help

Posted on 2009-04-05
8
467 Views
Last Modified: 2012-06-21
I want to extract a value from an json response string.

it looks like
{success:true, regcode:'49834', message:'kskkdsdf' }

JMeter let's you use regex to grab the value and tie it to a variable.

can someone help me create this regex expression.
0
Comment
Question by:bhomass
  • 5
  • 3
8 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 24085281
Which value? In Java or JavaScript?
0
 

Author Comment

by:bhomass
ID: 24089070
I want to get the regcode value. this is inside jmeter, I don't see how the question of java or javascript is relevant. maybe there is something I don't understand about jmeter. I was thinking of using the regular expression extractor. I would love to hear there are other ways.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24090014
>>I don't see how the question of java or javascript is relevant

It's relevant since the regex syntax is quite different in each case
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:bhomass
ID: 24090038
I see.
the example given in jmeter is
<a href="([^"]+)"
which extracts all the hyperlinks in the returned html page.

can you tell which camp this is in?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24090062
Having said that, regex itself shouldn't be relevant since a json api should be used really
0
 

Author Comment

by:bhomass
ID: 24090197
I am lost. the jmeter example gave no indication of a json api. it is a graphic based app, and it is using the regex expression I provided to extract the hyperlinks.

my question is, based on this, is it possible to figure what expression to use to extract the regcode value from a returned json string.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 75 total points
ID: 24090353
Try the following
regcode:'([^']+)

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24149925
:-)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question