You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by Mike Stover <ms...@apache.org> on 2002/07/13 05:31:08 UTC

built-in functions for jmeter

So, I have implemented enough that the first built-in function is now functional.  There is no 
GUI help for writing it yet, so using it will be a complete mystery to ya'll.  

Briefly, it's a function that let's you write a regular expression to grab a string from
the previous response text and make a new string with it.  The arguments are:

1. The regular expression to apply to the response text
2. How to generate a new string.  This is like a template string that includes groups from the 
regular expression.  You'll need to learn something about Perl regular expressions to 
understand this part.  You can refer to any particular group in your regular expression with a 
syntax like $1$ (gets replaced with the first group from your regex).
3. Which match to use.  Your regex might find multiple matches.  You can pick a number (1 is 
the first match, 2 the second, etc), you can use RAND to indicate JMeter should pick one at 
random, ALL means to use all matches (this is kinda complicated, so nevermind for now).
4.  The between text.  Say what?  Has to do with that ALL option mentioned above.
5.  Default text.  If your regex doesn't match, you can set the default string to use instead.

3,4, and 5 are optional and can be entirely absent.

Example:
${__regexFunction(<a href="(/[^"]*)",$1$,RAND,,/index.html)}

This finds links that start with '/' and groups the path to be used in the template.  The template 
is simply the path parsed from the regex.  A random match will be chosen each time the 
function is run, no between text is given, and the default is string if no match is found is 
'/index.html'.

If you need to use a comma in any of these values, you'll need to use the HTTP encoding for 
a comma, which you'll have to look up yourself.

I was surprisingly easy to use.  The hardest part is writing the regular expression, which 
shouldn't be much of a surprise, I guess.

--
Michael Stover
mstover1@apache.org
Yahoo IM: mstover_ya
ICQ: 152975688

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: built-in functions for jmeter

Posted by Scott Eade <se...@backstagetech.com.au>.
Mike,

These sound really useful.  I'll update and try them out in the next few
days.

Cheers,

Scott
-- 
Scott Eade
Backstage Technologies Pty. Ltd.
Web: http://www.backstagetech.com.au

> From: "Mike Stover" <ms...@apache.org>
> Reply-To: "JMeter Developers List" <jm...@jakarta.apache.org>
> Date: Fri, 12 Jul 2002 23:31:08 -0400
> To: jmeter-dev@jakarta.apache.org
> Subject: built-in functions for jmeter
> 
> So, I have implemented enough that the first built-in function is now
> functional.  There is no
> GUI help for writing it yet, so using it will be a complete mystery to ya'll.
> 
> Briefly, it's a function that let's you write a regular expression to grab a
> string from
> the previous response text and make a new string with it.  The arguments are:
> 
> 1. The regular expression to apply to the response text
> 2. How to generate a new string.  This is like a template string that includes
> groups from the 
> regular expression.  You'll need to learn something about Perl regular
> expressions to 
> understand this part.  You can refer to any particular group in your regular
> expression with a
> syntax like $1$ (gets replaced with the first group from your regex).
> 3. Which match to use.  Your regex might find multiple matches.  You can pick
> a number (1 is 
> the first match, 2 the second, etc), you can use RAND to indicate JMeter
> should pick one at
> random, ALL means to use all matches (this is kinda complicated, so nevermind
> for now).
> 4.  The between text.  Say what?  Has to do with that ALL option mentioned
> above.
> 5.  Default text.  If your regex doesn't match, you can set the default string
> to use instead.
> 
> 3,4, and 5 are optional and can be entirely absent.
> 
> Example:
> ${__regexFunction(<a href="(/[^"]*)",$1$,RAND,,/index.html)}
> 
> This finds links that start with '/' and groups the path to be used in the
> template.  The template
> is simply the path parsed from the regex.  A random match will be chosen each
> time the 
> function is run, no between text is given, and the default is string if no
> match is found is
> '/index.html'.
> 
> If you need to use a comma in any of these values, you'll need to use the HTTP
> encoding for 
> a comma, which you'll have to look up yourself.
> 
> I was surprisingly easy to use.  The hardest part is writing the regular
> expression, which
> shouldn't be much of a surprise, I guess.
> 
> --
> Michael Stover
> mstover1@apache.org
> Yahoo IM: mstover_ya
> ICQ: 152975688
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>