You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Surendra Viswanadham <sv...@gmail.com> on 2007/01/25 01:51:43 UTC

Dynamic Parameters with RegEx

Hi,

I am writing a simple test script for testing a web application. I am trying
to extract a parameter from the response of a request and use it as part of
subsequent requests.

Example
------------

if the response had the following data:
.....<a href="something.com?param1="val1"&param2="123456">...</a>.....

I want to extract 123456 which i know is going to be a 6 digit number.  I
tried the following after adding a regular expresion extractor as the post
processor for the request obtaining this response.

Ref Name: ref1
Regular Expression: param2=([\d{6}])
Template: $1$
Match No: 0
Default Value:

That script is never successful and goes to the default value.

1) Is the script right or is there something else wrong?
2) Do i need to declare ref1 in the user variables component or is it
implicit once i give it as a ref name ( I tried both ways)

Any ideas would help. Thanks.

Surendra

Re: Dynamic Parameters with RegEx

Posted by Marc Anthony Winoto <ma...@netregistry.com.au>.
Surendra Viswanadham wrote:
>
> Ref Name: ref1
> Regular Expression: param2=([\d{6}])
>

Aren't you missing the quotes around the regex?

So param2="([\d{6}])"

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


Re: Dynamic Parameters with RegEx

Posted by Surendra Viswanadham <sv...@gmail.com>.
Hey Sebb,
Thanks a lot. That worked pretty much. Additionally I needed some other
regex help but after looking around I found a pretty cool application,
http://weitz.de/regex-coach/ which helps the helpless :)


On 1/25/07, sebb <se...@gmail.com> wrote:
>
> On 25/01/07, Surendra Viswanadham <sv...@gmail.com> wrote:
> > Hi Sebb
> > Thanks for the response. Sorry for the mistaken info. There are no
> quotes
> > for either of the values. So the response would be
> >
> >  .....<a href="something.com?param1=val1&param2=123456">...</a>.....
> > In which case the regex param2=([\d{6}]) should work right ?
>
> No. Re-read my previous e-mail.
>
> > Suri
> >
> > On 1/24/07, sebb <se...@gmail.com> wrote:
> > >
> > > On 25/01/07, Surendra Viswanadham <sv...@gmail.com> wrote:
> > > > Hi,
> > > >
> > > > I am writing a simple test script for testing a web application. I
> am
> > > trying
> > > > to extract a parameter from the response of a request and use it as
> part
> > > of
> > > > subsequent requests.
> > > >
> > > > Example
> > > > ------------
> > > >
> > > > if the response had the following data:
> > > > .....<a href="something.com?param1=
> "val1"&param2="123456">...</a>.....
> > > >
> > > > I want to extract 123456 which i know is going to be a 6 digit
> > > number.  I
> > > > tried the following after adding a regular expresion extractor as
> the
> > > post
> > > > processor for the request obtaining this response.
> > > >
> > > > Ref Name: ref1
> > > > Regular Expression: param2=([\d{6}])
> > >
> > > The [ and ] are used to enclose character classes, i.e. [abc] means a
> > > or b or c - but only one such character.
> > >
> > > What you need is
> > >
> > > param2="(\d{6})"
> > >
> > > You need the final " otherwise it would match: param2="1234567
> > >
> > > > Template: $1$
> > > > Match No: 0
> > >
> > > 0 means pick a random match - did you mean that?
> > >
> > > > Default Value:
> > > >
> > > > That script is never successful and goes to the default value.
> > > >
> > > > 1) Is the script right or is there something else wrong?
> > > > 2) Do i need to declare ref1 in the user variables component or is
> it
> > > > implicit once i give it as a ref name ( I tried both ways)
> > > >
> > > > Any ideas would help. Thanks.
> > > >
> > > > Surendra
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> > >
> > >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

Re: Dynamic Parameters with RegEx

Posted by sebb <se...@gmail.com>.
On 25/01/07, Surendra Viswanadham <sv...@gmail.com> wrote:
> Hi Sebb
> Thanks for the response. Sorry for the mistaken info. There are no quotes
> for either of the values. So the response would be
>
>  .....<a href="something.com?param1=val1&param2=123456">...</a>.....
> In which case the regex param2=([\d{6}]) should work right ?

No. Re-read my previous e-mail.

> Suri
>
> On 1/24/07, sebb <se...@gmail.com> wrote:
> >
> > On 25/01/07, Surendra Viswanadham <sv...@gmail.com> wrote:
> > > Hi,
> > >
> > > I am writing a simple test script for testing a web application. I am
> > trying
> > > to extract a parameter from the response of a request and use it as part
> > of
> > > subsequent requests.
> > >
> > > Example
> > > ------------
> > >
> > > if the response had the following data:
> > > .....<a href="something.com?param1="val1"&param2="123456">...</a>.....
> > >
> > > I want to extract 123456 which i know is going to be a 6 digit
> > number.  I
> > > tried the following after adding a regular expresion extractor as the
> > post
> > > processor for the request obtaining this response.
> > >
> > > Ref Name: ref1
> > > Regular Expression: param2=([\d{6}])
> >
> > The [ and ] are used to enclose character classes, i.e. [abc] means a
> > or b or c - but only one such character.
> >
> > What you need is
> >
> > param2="(\d{6})"
> >
> > You need the final " otherwise it would match: param2="1234567
> >
> > > Template: $1$
> > > Match No: 0
> >
> > 0 means pick a random match - did you mean that?
> >
> > > Default Value:
> > >
> > > That script is never successful and goes to the default value.
> > >
> > > 1) Is the script right or is there something else wrong?
> > > 2) Do i need to declare ref1 in the user variables component or is it
> > > implicit once i give it as a ref name ( I tried both ways)
> > >
> > > Any ideas would help. Thanks.
> > >
> > > Surendra
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >
>
>

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


Re: Dynamic Parameters with RegEx

Posted by Surendra Viswanadham <sv...@gmail.com>.
Hi Sebb
Thanks for the response. Sorry for the mistaken info. There are no quotes
for either of the values. So the response would be

 .....<a href="something.com?param1=val1&param2=123456">...</a>.....
In which case the regex param2=([\d{6}]) should work right ?

Suri

On 1/24/07, sebb <se...@gmail.com> wrote:
>
> On 25/01/07, Surendra Viswanadham <sv...@gmail.com> wrote:
> > Hi,
> >
> > I am writing a simple test script for testing a web application. I am
> trying
> > to extract a parameter from the response of a request and use it as part
> of
> > subsequent requests.
> >
> > Example
> > ------------
> >
> > if the response had the following data:
> > .....<a href="something.com?param1="val1"&param2="123456">...</a>.....
> >
> > I want to extract 123456 which i know is going to be a 6 digit
> number.  I
> > tried the following after adding a regular expresion extractor as the
> post
> > processor for the request obtaining this response.
> >
> > Ref Name: ref1
> > Regular Expression: param2=([\d{6}])
>
> The [ and ] are used to enclose character classes, i.e. [abc] means a
> or b or c - but only one such character.
>
> What you need is
>
> param2="(\d{6})"
>
> You need the final " otherwise it would match: param2="1234567
>
> > Template: $1$
> > Match No: 0
>
> 0 means pick a random match - did you mean that?
>
> > Default Value:
> >
> > That script is never successful and goes to the default value.
> >
> > 1) Is the script right or is there something else wrong?
> > 2) Do i need to declare ref1 in the user variables component or is it
> > implicit once i give it as a ref name ( I tried both ways)
> >
> > Any ideas would help. Thanks.
> >
> > Surendra
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

Re: Dynamic Parameters with RegEx

Posted by sebb <se...@gmail.com>.
On 25/01/07, Surendra Viswanadham <sv...@gmail.com> wrote:
> Hi,
>
> I am writing a simple test script for testing a web application. I am trying
> to extract a parameter from the response of a request and use it as part of
> subsequent requests.
>
> Example
> ------------
>
> if the response had the following data:
> .....<a href="something.com?param1="val1"&param2="123456">...</a>.....
>
> I want to extract 123456 which i know is going to be a 6 digit number.  I
> tried the following after adding a regular expresion extractor as the post
> processor for the request obtaining this response.
>
> Ref Name: ref1
> Regular Expression: param2=([\d{6}])

The [ and ] are used to enclose character classes, i.e. [abc] means a
or b or c - but only one such character.

What you need is

param2="(\d{6})"

You need the final " otherwise it would match: param2="1234567

> Template: $1$
> Match No: 0

0 means pick a random match - did you mean that?

> Default Value:
>
> That script is never successful and goes to the default value.
>
> 1) Is the script right or is there something else wrong?
> 2) Do i need to declare ref1 in the user variables component or is it
> implicit once i give it as a ref name ( I tried both ways)
>
> Any ideas would help. Thanks.
>
> Surendra
>
>

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