Just replace "." with something that stops it matching beyond the end of the
"cat phrase", e.g.
<sp>cat<sp>[^<]*?id=(\d+)<sp>
i.s. match all but "<".
or
<sp>cat<sp>[\w\s]*?id=(\d+)<sp>
if there can only be letters and whitespace between "cat" and "id=".
You can always add extra context at the start and end of the regex to tie it
down further.
I don't think back references are necessary here.
S.
-----Original Message-----
From: Andrew Roughan [mailto:[EMAIL PROTECTED]
Sent: 04 August 2004 02:41
To: JMeter Users List
Subject: RE: How to parse responses
Using The Regex Coach
<sp>cat<sp>.*?id=(\d+)<sp>
gets 15 from the following example
<form>
blah blah cat blah blah noid blah blah
</form>
<form>
blah blah horse blah blah id=15 blah blah
</form>
What I think I need is a search within a backreference
(<form.*<sp>cat<sp>.*?</form)\1id=(\d+)<sp>
however this does not work within The Regex Coach.
I tried this inside JMeter RegExp Extractor
regex: (<form.*<sp>cat<sp>.*?</form)
template: $1$id=(\d+)<sp>
but that did not work either.
What am I missing?
Thanks,
Andrew
--- "BAZLEY, Sebastian"
<[EMAIL PROTECTED]> wrote:
> The regex extractor and function both allow one to
> specify a default value,
> which is returned if the regex does not match.
>
> Try it and see.
>
> You can use a dummy JavaSampler to display the
> contents of any variable(s)
> by including a reference to the variable(s).
>
> S.
> -----Original Message-----
> From: Andrew Roughan [mailto:[EMAIL PROTECTED]
> Sent: 03 August 2004 06:20
> To: JMeter Users List
> Subject: RE: How to parse responses
>
>
> Thanks for the response Sebastian.
>
> I think the suggestion will work well for the first
> part of my requirement:
> > I want to extract the value of id from the form
> > section where the text includes cat. e.g. 54
>
> However, I don't think it will work for this second
> part:
> > Further, if id= does not exist within the form
> > section where the text includes cat, then return
> > false or similar.
>
> e.g. If the response was like this:
>
> <form>
> blah blah dog blah blah id=32 blah blah
> </form>
> <form>
> blah blah cat blah blah noid blah blah
> </form>
> <form>
> blah blah horse blah blah id=15 blah blah
> </form>
>
> in this case I think the suggested regexp would
> return
> 15?
>
> I was thinking that ForEach may assist if I actually
> had to go through a list of extracted values (e.g.
> dog
> id=32, cat id=54, horse id=15). However this may not
> be necessary.
>
> Cheers,
> Andrew
>
> --- "BAZLEY, Sebastian"
> <[EMAIL PROTECTED]> wrote:
> > Try a regex of the form
> >
> > <sp>cat<sp>.*?id=(\d+)<sp>
> >
> > where <sp> = space.
> >
> > You don't say how you want to use the id value, so
> > it is not clear whether
> > the ForEach controller would be useful or not.
> >
> > See the JMeter Wiki for a pointer to a very useful
> > regex tester.
> >
> > S.
> > -----Original Message-----
> > From: Andrew Roughan
> [mailto:[EMAIL PROTECTED]
> > Sent: 22 July 2004 13:30
> > To: [EMAIL PROTECTED]
> > Subject: How to parse responses
> >
> >
> > Hi, Can someone please tell me whether what I want
> > to
> > do is possible, and if it is, give a suggestion on
> > how
> > it can be done?
> >
> > If I have a HTML response similar to
> >
> > ...
> > <form>
> > blah blah dog blah blah id=32 blah blah
> > </form>
> > <form>
> > blah blah cat blah blah id=54 blah blah
> > </form>
> > <form>
> > blah blah horse blah blah id=15 blah blah
> > </form>
> > ...
> >
> > I want to extract the value of id from the form
> > section where the text includes cat. e.g. 54
> >
> > Further, if id= does not exist within the form
> > section where the text includes cat, then return
> > false
> > or similar.
> >
> > I've looked at Regular Expression Extractor (using
> > <form.*?</form as a start) and the ForEach
> > Controller
> > and but I haven't yet worked out how this could be
> > done. If this is possible, I sure would like a
> > pointer
> > on how to go about it. If it isnt, knowing that
> > would
> > be good too!
> >
> > Thanks,
> > Andrew
Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_______________________________________________________
This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive this
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network, the
sender does not warrant that this transmission is virus-free and will
not be liable for any damages resulting from any virus transmitted.
_______________________________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]