You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Nithya Prakash <ni...@gmail.com> on 2012/05/24 17:54:55 UTC

Require help in Regular Expression!!!

Hi,

I want to fetch few things using regular expression but unable to get the
parameters.

*While i capture the action using HTTP proxy i get the parameter as *

{'partId':'542024','partNumber':'SRW224G4P-K9-AU','productPart':'SRW224G4P-K9-AU','validationStatus':'not
validated'},{'partId':'542027','partNumber':'UC560-T1E1-K9','productPart':'UC560-T1E1-K9','validationStatus':'not
validated'},{'partId':'542028','partNumber':'CP-7925G-W-K9','productPart':'CP-7925G-W-K9','validationStatus':'not
validated'},{'partId':'542029','partNumber':'CP-7962G=','productPart':'CP-7962G=','validationStatus':'not
validated'}

*When i take the HTML page of this to capture the expression *

[{"equipmentPart":{"allAttributes":{"compositePartName":"SRW224G4P-K9-AU
","equipmentPartPhysicalSiteId":"73411","equipmentPartSiteId":73414,"equipmentPartId":
542024,"productPartName":"SRW224G4P-K9-AU","equipmentPartName":"SRW224G4P-K9-AU"}},"updatedTimeStamp":1337838775000,"solutionEntityId":542227,"solutionId":13959179,"status":"validation
ok","id":95509,"createdTimeStamp":1337838666000,"messages":", Non
Configurable"},{"equipmentPart":{"allAttributes":{"compositePartName":"
UC560-T1E1-K9
","equipmentPartPhysicalSiteId":"73411","equipmentPartSiteId":73412,"equipmentPartId"
:542027,"productPartName":"UC560-T1E1-K9","equipmentPartName":"UC560-T1E1-K9"}},"updatedTimeStamp":1337838775000,"solutionEntityId":542230,"solutionId":13959179,"status":"validation
ok","id":95510,"createdTimeStamp":1337838666000,"messages":", Non
Configurable"}]

Now i need to to capture the 'equipmentPartId: 542024' and
'compositePartName: SRW224G4P-K9-AU from the HTML page. Similarly there are
10 more expressions of the same manner.

What regular expression to be used to fetch the id and and the part name
and replace in http request ??


Thanks

Re: Require help in Regular Expression!!!

Posted by Flavio Cysne <fl...@gmail.com>.
the dot character in a regex will produce a hunger expression, try to avoid
it.

use, instead, \d for numbers only pattern -> equipmentPartId":"(\d+?)"

using a negation pattern is a better way to avoid the dot ->
productPartName":"([^"]+?)"

2012/5/25 Felix Frank <ff...@mpexnet.de>

> On 05/25/2012 09:10 AM, venkatakurathi wrote:
> > add debug sampler to the transaction & run the script.
> > look into the response of debug sampler ,u can find the multiple values
> > extracted by your expression in name value format.
> > it gives you a better undertsanding to how to proceed further.
>
> Right.
>
> You will probably need to do something like this as well:
> http://theworkaholic.blogspot.com/2010/03/dynamic-parameters-in-jmeter.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>

Re: Require help in Regular Expression!!!

Posted by Deepak Shetty <sh...@gmail.com>.
with a code sample
http://theworkaholic.blogspot.com/2012/05/json-in-jmeter.html

regards
deepak

On Fri, May 25, 2012 at 9:50 AM, Deepak Shetty <sh...@gmail.com> wrote:

> Hi
> An alternative to consider is to download a JSON library (json.org) and
> parse the response string using the library and then iterate over it to add
> the parameters to the request instead of regex.
>
> regards
> deepak
>
>
> On Fri, May 25, 2012 at 12:43 AM, Felix Frank <ff...@mpexnet.de> wrote:
>
>> On 05/25/2012 09:10 AM, venkatakurathi wrote:
>> > add debug sampler to the transaction & run the script.
>> > look into the response of debug sampler ,u can find the multiple values
>> > extracted by your expression in name value format.
>> > it gives you a better undertsanding to how to proceed further.
>>
>> Right.
>>
>> You will probably need to do something like this as well:
>>
>> http://theworkaholic.blogspot.com/2010/03/dynamic-parameters-in-jmeter.html
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>> For additional commands, e-mail: user-help@jmeter.apache.org
>>
>>
>

Re: Require help in Regular Expression!!!

Posted by Deepak Shetty <sh...@gmail.com>.
Hi
An alternative to consider is to download a JSON library (json.org) and
parse the response string using the library and then iterate over it to add
the parameters to the request instead of regex.

regards
deepak

On Fri, May 25, 2012 at 12:43 AM, Felix Frank <ff...@mpexnet.de> wrote:

> On 05/25/2012 09:10 AM, venkatakurathi wrote:
> > add debug sampler to the transaction & run the script.
> > look into the response of debug sampler ,u can find the multiple values
> > extracted by your expression in name value format.
> > it gives you a better undertsanding to how to proceed further.
>
> Right.
>
> You will probably need to do something like this as well:
> http://theworkaholic.blogspot.com/2010/03/dynamic-parameters-in-jmeter.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>

Re: Require help in Regular Expression!!!

Posted by Felix Frank <ff...@mpexnet.de>.
On 05/25/2012 09:10 AM, venkatakurathi wrote:
> add debug sampler to the transaction & run the script.
> look into the response of debug sampler ,u can find the multiple values
> extracted by your expression in name value format.
> it gives you a better undertsanding to how to proceed further.

Right.

You will probably need to do something like this as well:
http://theworkaholic.blogspot.com/2010/03/dynamic-parameters-in-jmeter.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: Require help in Regular Expression!!!

Posted by venkatakurathi <ve...@hotmail.com>.
add debug sampler to the transaction & run the script.
look into the response of debug sampler ,u can find the multiple values
extracted by your expression in name value format.
it gives you a better undertsanding to how to proceed further.

-----
Venkat Akurathi
91-9703186688
--
View this message in context: http://jmeter.512774.n5.nabble.com/Require-help-in-Regular-Expression-tp5713320p5713342.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: Require help in Regular Expression!!!

Posted by Nithya Prakash <ni...@gmail.com>.
Thank you Venkat. I'm able to fetch for individual part id and product
name.

Now how will i accommodate my http request with many of such
expressions.... like

{'partId':${part1id}','partNumber':'${part1name}',
'productPart':'SRW224G4P-K9-AU','validationStatus':'not
validated'},{'partId':'542027','partNumber':'UC560-T1E1-K9',
'productPart':'UC560-T1E1-K9','validationStatus':'not
validated'},{'partId':'542028','partNumber':'CP-7925G-W-K9',
'productPart':'CP-7925G-W-K9','validationStatus':'not
validated'},{'partId':'542029','partNumber':'CP-7962G=','
productPart':'CP-7962G=','validationStatus':'not validated'}

and so on ?? now i have few parts i could do it... tomorrow if the parts
keep increasing i could not handle that..... so require a solution in such
a way that i capture the entire section and pull only id and partnumber to
my http request.....

is it possible to do with regular expression or is there any other way out??

Thanks

On Thu, May 24, 2012 at 10:15 PM, venkatakurathi <
venkat.akurathi@hotmail.com> wrote:

>
> equipmentPartId":(.+?),"
> will give you 542024
>
> productPartName":"(.+?)",
> will give you UC560-T1E1-K9
>
>
> -----
> Venkat Akurathi
> 91-9703186688
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/Require-help-in-Regular-Expression-tp5713320p5713321.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>


-- 
Nithya Prakash.L

Re: Require help in Regular Expression!!!

Posted by venkatakurathi <ve...@hotmail.com>.
equipmentPartId":(.+?),"
will give you 542024

productPartName":"(.+?)",
will give you UC560-T1E1-K9


-----
Venkat Akurathi
91-9703186688
--
View this message in context: http://jmeter.512774.n5.nabble.com/Require-help-in-Regular-Expression-tp5713320p5713321.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org