You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Angelo Di Placido <an...@talkshoe.com> on 2007/06/07 18:20:04 UTC

Running Regular Expression extractor on the results of JDBC Requests

Hello All,

 

I am running the jdbc request sampler to execute a query "select userName,
password from User limit 10" against a mysql database.  The result that
comes back is:

 

userName         password

user1    password1

user2    password2

user3    password3

user4    password4

user5    password5

user6    password6

user7    password7

user8    password8

user9    password9

user10  password10

 

Now I would like to create a regular expression that extracts all the users
and passwords and use the results in a foreach type controller.  Problem is
I need to not match "userName     password".

 

I have tried the regular expression
"(?!userName)([a-zA-Z0-9]+)\s+([a-zA-Z0-9]+)" .  This does not match
"userName" but does match "serName"!

 

So the problem is solved either:

1. not having the jdbc request sampler return the heading row ("userName
password"), or

2. fix the regular expression

 

Any help would be appreciated.

 

Thanks,

 

Angelo.

 


Re: Running Regular Expression extractor on the results of JDBC Requests

Posted by sebb <se...@gmail.com>.
On 4 June 2011 10:30, pavelz <za...@gmail.com> wrote:
> Bumping up a question. Anybody can help with the issue? I am having the same
> problem myself..

This is a very old thread; JMeter has been updated since then so
answers may change.

Please start a new thread with details of the problem you are having.

> Thanks, Pavel
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/Running-Regular-Expression-extractor-on-the-results-of-JDBC-Requests-tp522245p4453545.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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: Running Regular Expression extractor on the results of JDBC Requests

Posted by pavelz <za...@gmail.com>.
Bumping up a question. Anybody can help with the issue? I am having the same
problem myself..
Thanks, Pavel

--
View this message in context: http://jmeter.512774.n5.nabble.com/Running-Regular-Expression-extractor-on-the-results-of-JDBC-Requests-tp522245p4453545.html
Sent from the JMeter - User mailing list archive at Nabble.com.

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


Re: Running Regular Expression extractor on the results of JDBC Requests

Posted by sebb <se...@gmail.com>.
On 07/06/07, Angelo Di Placido <an...@talkshoe.com> wrote:
> I did try anchoring to the start and end of the line with the pattern "
> ^(?!userName)([a-zA-Z0-9]+)\s+(?!password$)([a-zA-Z0-9]+)"

That is not the same as any of the examples I gave.

> This regexp works when I test it using http://regexlib.com/RETester.aspx.
> But I can't seem to get it to work with jmeter regular expression extractor.
>

Because that is not an ORO RE tester.

Try

http://jakarta.apache.org/oro/demo.html

instead

As for the RE, I simplified it to

(?m)^(?!userName)(\S+)\s+(\S+)

> Angelo.
>
> -----Original Message-----
> From: sebb [mailto:sebbaz@gmail.com]
> Sent: Thursday, June 07, 2007 1:25 PM
> To: JMeter Users List
> Subject: Re: Running Regular Expression extractor on the results of JDBC
> Requests
>
> On 07/06/07, Angelo Di Placido <an...@talkshoe.com> wrote:
> > Hello All,
> >
> >
> >
> > I am running the jdbc request sampler to execute a query "select userName,
> > password from User limit 10" against a mysql database.  The result that
> > comes back is:
> >
> >
> >
> > userName         password
> >
> > user1    password1
> >
> [...]
> > user10  password10
> >
> > Now I would like to create a regular expression that extracts all the
> users
> > and passwords and use the results in a foreach type controller.  Problem
> is
> > I need to not match "userName     password".
> >
> >
> >
> > I have tried the regular expression
> > "(?!userName)([a-zA-Z0-9]+)\s+([a-zA-Z0-9]+)" .  This does not match
> > "userName" but does match "serName"!
> >
>
> That's how negative lookahead is supposed to work.
>
> When the text is "userName" it sees "userName" and fails.
> But when it reaches "serName" it succeeds.
>
> >
> >
> > So the problem is solved either:
> >
> > 1. not having the jdbc request sampler return the heading row ("userName
> > password"), or
> >
> > 2. fix the regular expression
> >
>
> Negative lookahead is not much use at the start of an RE, as you have found.
>
> Try either
>
> "^(?!userName)([a-zA-Z0-9]+)\s+([a-zA-Z0-9]+)"
>
> which anchors the negative match, or
>
> "([a-zA-Z0-9]+)\s+(?!password)([a-zA-Z0-9]+)"
>
> which uses the leading \s+ to anchor the NLA or even
>
> "^(?!userName)([a-zA-Z0-9]+)\s+(?!password)([a-zA-Z0-9]+)"
>
> to reject username and password.
>
> >
> > Any help would be appreciated.
> >
> >
> >
> > Thanks,
> >
> >
> >
> > Angelo.
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> 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
>
>

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


RE: Running Regular Expression extractor on the results of JDBC Requests

Posted by Angelo Di Placido <an...@talkshoe.com>.
All,

I did get this work by using the multiline modifier.  So now my expression
is "(?m)^(?!userName)([a-zA-Z0-9]+)\s+(?!password$)([a-zA-Z0-9]+)"

Angelo.

-----Original Message-----
From: Angelo Di Placido [mailto:angelod@talkshoe.com] 
Sent: Thursday, June 07, 2007 5:42 PM
To: 'JMeter Users List'
Subject: RE: Running Regular Expression extractor on the results of JDBC
Requests

I did try anchoring to the start and end of the line with the pattern "
^(?!userName)([a-zA-Z0-9]+)\s+(?!password$)([a-zA-Z0-9]+)"

This regexp works when I test it using http://regexlib.com/RETester.aspx.
But I can't seem to get it to work with jmeter regular expression extractor.

Angelo.

-----Original Message-----
From: sebb [mailto:sebbaz@gmail.com] 
Sent: Thursday, June 07, 2007 1:25 PM
To: JMeter Users List
Subject: Re: Running Regular Expression extractor on the results of JDBC
Requests

On 07/06/07, Angelo Di Placido <an...@talkshoe.com> wrote:
> Hello All,
>
>
>
> I am running the jdbc request sampler to execute a query "select userName,
> password from User limit 10" against a mysql database.  The result that
> comes back is:
>
>
>
> userName         password
>
> user1    password1
>
[...]
> user10  password10
>
> Now I would like to create a regular expression that extracts all the
users
> and passwords and use the results in a foreach type controller.  Problem
is
> I need to not match "userName     password".
>
>
>
> I have tried the regular expression
> "(?!userName)([a-zA-Z0-9]+)\s+([a-zA-Z0-9]+)" .  This does not match
> "userName" but does match "serName"!
>

That's how negative lookahead is supposed to work.

When the text is "userName" it sees "userName" and fails.
But when it reaches "serName" it succeeds.

>
>
> So the problem is solved either:
>
> 1. not having the jdbc request sampler return the heading row ("userName
> password"), or
>
> 2. fix the regular expression
>

Negative lookahead is not much use at the start of an RE, as you have found.

Try either

"^(?!userName)([a-zA-Z0-9]+)\s+([a-zA-Z0-9]+)"

which anchors the negative match, or

"([a-zA-Z0-9]+)\s+(?!password)([a-zA-Z0-9]+)"

which uses the leading \s+ to anchor the NLA or even

"^(?!userName)([a-zA-Z0-9]+)\s+(?!password)([a-zA-Z0-9]+)"

to reject username and password.

>
> Any help would be appreciated.
>
>
>
> Thanks,
>
>
>
> Angelo.
>
>
>
>

---------------------------------------------------------------------
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



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


RE: Running Regular Expression extractor on the results of JDBC Requests

Posted by Angelo Di Placido <an...@talkshoe.com>.
I did try anchoring to the start and end of the line with the pattern "
^(?!userName)([a-zA-Z0-9]+)\s+(?!password$)([a-zA-Z0-9]+)"

This regexp works when I test it using http://regexlib.com/RETester.aspx.
But I can't seem to get it to work with jmeter regular expression extractor.

Angelo.

-----Original Message-----
From: sebb [mailto:sebbaz@gmail.com] 
Sent: Thursday, June 07, 2007 1:25 PM
To: JMeter Users List
Subject: Re: Running Regular Expression extractor on the results of JDBC
Requests

On 07/06/07, Angelo Di Placido <an...@talkshoe.com> wrote:
> Hello All,
>
>
>
> I am running the jdbc request sampler to execute a query "select userName,
> password from User limit 10" against a mysql database.  The result that
> comes back is:
>
>
>
> userName         password
>
> user1    password1
>
[...]
> user10  password10
>
> Now I would like to create a regular expression that extracts all the
users
> and passwords and use the results in a foreach type controller.  Problem
is
> I need to not match "userName     password".
>
>
>
> I have tried the regular expression
> "(?!userName)([a-zA-Z0-9]+)\s+([a-zA-Z0-9]+)" .  This does not match
> "userName" but does match "serName"!
>

That's how negative lookahead is supposed to work.

When the text is "userName" it sees "userName" and fails.
But when it reaches "serName" it succeeds.

>
>
> So the problem is solved either:
>
> 1. not having the jdbc request sampler return the heading row ("userName
> password"), or
>
> 2. fix the regular expression
>

Negative lookahead is not much use at the start of an RE, as you have found.

Try either

"^(?!userName)([a-zA-Z0-9]+)\s+([a-zA-Z0-9]+)"

which anchors the negative match, or

"([a-zA-Z0-9]+)\s+(?!password)([a-zA-Z0-9]+)"

which uses the leading \s+ to anchor the NLA or even

"^(?!userName)([a-zA-Z0-9]+)\s+(?!password)([a-zA-Z0-9]+)"

to reject username and password.

>
> Any help would be appreciated.
>
>
>
> Thanks,
>
>
>
> Angelo.
>
>
>
>

---------------------------------------------------------------------
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: Running Regular Expression extractor on the results of JDBC Requests

Posted by sebb <se...@gmail.com>.
On 07/06/07, Angelo Di Placido <an...@talkshoe.com> wrote:
> Hello All,
>
>
>
> I am running the jdbc request sampler to execute a query "select userName,
> password from User limit 10" against a mysql database.  The result that
> comes back is:
>
>
>
> userName         password
>
> user1    password1
>
[...]
> user10  password10
>
> Now I would like to create a regular expression that extracts all the users
> and passwords and use the results in a foreach type controller.  Problem is
> I need to not match "userName     password".
>
>
>
> I have tried the regular expression
> "(?!userName)([a-zA-Z0-9]+)\s+([a-zA-Z0-9]+)" .  This does not match
> "userName" but does match "serName"!
>

That's how negative lookahead is supposed to work.

When the text is "userName" it sees "userName" and fails.
But when it reaches "serName" it succeeds.

>
>
> So the problem is solved either:
>
> 1. not having the jdbc request sampler return the heading row ("userName
> password"), or
>
> 2. fix the regular expression
>

Negative lookahead is not much use at the start of an RE, as you have found.

Try either

"^(?!userName)([a-zA-Z0-9]+)\s+([a-zA-Z0-9]+)"

which anchors the negative match, or

"([a-zA-Z0-9]+)\s+(?!password)([a-zA-Z0-9]+)"

which uses the leading \s+ to anchor the NLA or even

"^(?!userName)([a-zA-Z0-9]+)\s+(?!password)([a-zA-Z0-9]+)"

to reject username and password.

>
> Any help would be appreciated.
>
>
>
> Thanks,
>
>
>
> Angelo.
>
>
>
>

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