Solved

JMeter regex help

Posted on 2009-04-05
8
465 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping1 challenge 7 73
mockito example issue 8 62
replace a word with other 1 40
configure dependency in POM for new database 3 17
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now