Require help in Regular Expression!!!

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Require help in Regular Expression!!!

Nithya Prakash
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
Reply | Threaded
Open this post in threaded view
|

Re: Require help in Regular Expression!!!

venkatakurathi

equipmentPartId":(.+?),"
will give you 542024

productPartName":"(.+?)",
will give you UC560-T1E1-K9
Venkat Akurathi 91-9703186688
Reply | Threaded
Open this post in threaded view
|

Re: Require help in Regular Expression!!!

Nithya Prakash
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 <
[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Nithya Prakash.L
Reply | Threaded
Open this post in threaded view
|

Re: Require help in Regular Expression!!!

venkatakurathi
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
Reply | Threaded
Open this post in threaded view
|

Re: Require help in Regular Expression!!!

Felix Frank-2
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Require help in Regular Expression!!!

Flavio Cysne
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 <[hidden email]>

> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Require help in Regular Expression!!!

shettyd
In reply to this post by Felix Frank-2
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 <[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Require help in Regular Expression!!!

shettyd
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 <[hidden email]> 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 <[hidden email]> 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: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>