At least on Perl v5.8.1, this will do the magic:

^(?>.*?foo){8}(?!.*?foo)

Explanation:

^ anchors the match at the beginning of the string

(?>X) is a "do not backtrack" or "intependent subexpression". Whatever is matched by pattern X at first shot will be "bound" to this subexpression, and won't be "given back" to be matched by a later .*

X*? is a non-greedy X* : it will match as little as possible, instead of as much as possible as X* does.

X{8} is exactly equivalent to X{8,8}.

(?!X) is a negative lookahead: will match only if what follows does not match X.

I really don't know whether ORO will support "?>", which is described in man perlre as a "highly experimental feature".

To complete the picture, use:

(?s)^(?>.*?foo){8}(?!.*foo)

Which will match responses containing 8 (but not 9) "foo"s independently of whether they occur in the same or separate lines.

Good luck.

--
Salut,

Jordi.

BAZLEY, Sebastian wrote:
True, but won't it stop looking when it has found 8 matches?
i.e. there could be more "sample"s later in the buffer?

==

One could try anchoring the last sample:

(sample.*){7,7}(sample.*$){1,1}

but I think that would suffer from the same problem as the negative
look-ahead.
It may be tricky stopping the matcher from working its way past the leading
samples.

S.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 01 October 2003 13:31
To: JMeter Users List
Subject: RE: Using Response Assertion to evaluate HTML details


Also,


(sample.*){8,8} will match exactly 8 occurrences.

-Mike

On 1 Oct 2003 at 10:41, BAZLEY, Sebastian wrote:


JMeter uses Jakarta ORO (http://jakarta.apache.org/oro/index.html) to
implement Perl5 patterns.

Since Perl includes multi-line patterns using the "m" and "s"

modifiers:


<quote from Perlre document>
m

Treat string as multiple lines. That is, change ``^'' and ``$'' from
matching the start or end of the string to matching the start or end

of any


line anywhere within the string.

s

Treat string as single line. That is, change ``.'' to match any

character


whatsoever, even a newline, which normally it would not match. </quote>

It looks as though "s" might be best in your case.

As a start, you could try matching sample 8 times using

something like:


(sample.*){8}
This would eliminate fewer than 8 occurrences.

(sample.*){9} should catch ones with 9 or more.

So you could use two assertions; the first to match 8 samples, the

second to


NOT match 9.

The tricky bit would be combining the two, as

(sample.*){8}(?!.*sample)


would presumably be happy to match 9 occurrences by starting

the match with


the second sample.

I'm afraid I'll have to leave solving that as an exercise for the

reader, as


I don't know how myself.

I could not find anything on the ORO pages about exactly what

REs it


supports, or if there are any exclusions.

Perl itself has pretty good documentation on regular expressions.

If you


have a Perl installation, try perldoc perlre, perlrequick or

perlretut.


There is online documentation on the Activestate web-site and

elsewehere.


Hope this will help you get started. If you find a good solution,

please


share it with us!

S.*n
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 01 October 2003 00:10
To: JMeter Users List
Subject: Re: Using Response Assertion to evaluate HTML details


Currently, the Response Assertion only supports a yes/no

response


to whether the text includes the regex. Supporting match counts would be useful too, I think.

-Mike

On 30 Sep 2003 at 15:39, Dan Yuen wrote:


I've started looking at JMeter for testing some html
pages on a web app.  I was wondering how much
flexibility i might have with the regular expressions
in the Response Assertion.

I've seen how an Assertion Results can report back
whether or not it finds an occurrence of a certain
pattern in a line.  But can I use this feature to, for
example, verify that my response is an html page with
exactly eight occurrences of the word "sample" within
a
<pre></pre> tag somewhere in the body of the page?

Am I limited to testing for only patterns contained in
a single line?

Thanks very much.

Dan Yuen


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to