You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Jose Pablo Sarco <jo...@ar.neoris.com> on 2009/04/01 17:15:12 UTC

Is possible extract a group of values with Regular Expression extractor?

Hi all,

 

I'm using Jmeter 2.3.2 on XP. I don't know if it's possible use the
Regular Expression extractor to extract a group of values from a
response.

 

I have this response:

 

<input type="checkbox" name="seleccionado" value="6001000123|6001000123"
checked="checked"
onclick="updateSelectedQuantity(this,'PrestadoresSimulacion');
updateState();" disabled="disabled" id="PrestadoresSimulacion_items">

<input type="checkbox" name="seleccionado" value="6091000123|6091000123"
checked="checked"
onclick="updateSelectedQuantity(this,'PrestadoresSimulacion');
updateState();" disabled="disabled" id="PrestadoresSimulacion_items">

<input type="checkbox" name="seleccionado" value="6901000123|6901000123"
checked="checked"
onclick="updateSelectedQuantity(this,'PrestadoresSimulacion');
updateState();" disabled="disabled" id="PrestadoresSimulacion_items">

....

....

....

<input type="checkbox" name="seleccionado" value="7001000123|7001000123"
checked="checked"
onclick="updateSelectedQuantity(this,'PrestadoresSimulacion');
updateState();" disabled="disabled" id="PrestadoresSimulacion_items">

 

I need extract all the values:

 

"6001000123|6001000123"; "6091000123|6091000123";
"6901000123|6901000123"; ...; "7001000123|7001000123"

 

 

I have the regular expression to extract 1 of the values; but is
possible extract all the values with Regular Expression extractor? How?

 

Thanks in advance to all


#################################################################################################################
Este documento puede incluir informaci�n confidencial y propiedad de Neoris y deber� ser le�do solamente por la 
o las personas a quienes est� dirigido. Si usted ha recibido este mensaje por error, por favor avise 
inmediatamente al remitente contestando y eliminando este correo. Cualquier punto de vista u opiniones expresadas 
en este mensaje son del remitente y no necesariamente coinciden con aquellas de Neoris. Este documento no deber� 
ser reproducido, copiado, distribuido, publicado, ni modificado por terceros sin la autorizaci�n por escrito de Neoris. 

Este mensaje ha sido verificado contra virus. Vis�tenos en www.neoris.com. 
#################################################################################################################

Re: Is possible extract a group of values with Regular Expression extractor?

Posted by guru <pr...@gmail.com>.
I see what Regular expression was doing.
For example, lets say i have the following response:
<ns10:UserRowId="1"><ns6:UserId>ffffffff521cf326e4b05c028a28007d</ns6:UserId><ns6:FirstName>1aug2713</ns6:FirstName><ns6:LastName>1aug2713</ns6:LastName><ns6:Gender>Unspecified</ns6:Gender><ns6:UserName>1aug2713</ns6:UserName><ns6:Password>password1</ns6:Password><ns6:EncryptionType>SHA</ns6:EncryptionType><ns6:AuthenticationType>SSO</ns6:AuthenticationType><ns6:BusinessRuleSet>CG</ns6:BusinessRuleSet><ns6:AutoGenerated>false</ns6:AutoGenerated></ns10:User>
<ns10:UserRowId="2"><ns6:UserId>ffffffff521cf326e4b05c028a28007e</ns6:UserId><ns6:FirstName>2aug2713</ns6:FirstName><ns6:LastName>2aug2713</ns6:LastName><ns6:Gender>Unspecified</ns6:Gender><ns6:UserName>2aug2713</ns6:UserName><ns6:Password>password1</ns6:Password><ns6:EncryptionType>SHA</ns6:EncryptionType><ns6:AuthenticationType>SSO</ns6:AuthenticationType><ns6:BusinessRuleSet>CG</ns6:BusinessRuleSet><ns6:AutoGenerated>false</ns6:AutoGenerated></ns10:User>
<ns10:UserRowId="3"><ns6:UserId>ffffffff521cf326e4b05c028a28007f</ns6:UserId><ns6:FirstName>3aug2713</ns6:FirstName><ns6:LastName>3aug2713</ns6:LastName><ns6:Gender>Unspecified</ns6:Gender><ns6:UserName>3aug2713</ns6:UserName><ns6:Password>password1</ns6:Password><ns6:EncryptionType>SHA</ns6:EncryptionType><ns6:AuthenticationType>SSO</ns6:AuthenticationType><ns6:BusinessRuleSet>CG</ns6:BusinessRuleSet><ns6:AutoGenerated>false</ns6:AutoGenerated></ns10:User>
My Regular expression extractor is as follow:
Reference Name: username
Regular Expression:
<ns6:UserId>(.+?)</ns6:UserId>.*<ns6:UserName>(.+?)</ns6:UserName>
Template: $1$ $2$
Match No.= 1
 The value that is being saved on my txt file that I mentioned is like this.
ffffffff521cf326e4b05c028a28007d,3aug2713
So, it is saving the first userId and the last Username.
When I tried -1, on my txt file it is saving null.
Just to do some more research on it, I changed my regular expression as
below and I also added debug sampler
Reference Name: username
Regular Expression: <ns6:UserId>(.+?)</ns6:UserId
Template: $1$
Match No.= -1
When I look at debug Sampler Response data with above configuration I see
it is extracting all three UserId and I changed the jmeter.property file as
sample_variables=username_1,username_2,username_3
This let me save all 3 userId in a file i have mentioned. But the issue is
If i have 500 UserId, do I have to mention all 500 in property file. I have
tried
sample_variables=username_n but the value that got saved in a file is null.
JMeterVariables:
JMeterThread.last_sample_ok=true
JMeterThread.pack=org.apache.jmeter.threads.SamplePackage@1ed2e55e
START.HMS=163623
START.MS <http://start.ms/>=1377646583923
START.YMD=20130827
TESTSTART.MS <http://teststart.ms/>=1377647571490
username_1=ffffffff521cf326e4b05c028a28007d
username_1_g=1
username_1_g0=<ns6:UserId>ffffffff521cf326e4b05c028a28007d</ns6:UserId>
username_1_g1=ffffffff521cf326e4b05c028a28007d
username_2=ffffffff521cf326e4b05c028a28007e
username_2_g=1
username_2_g0=<ns6:UserId>ffffffff521cf326e4b05c028a28007e</ns6:UserId>
username_2_g1=ffffffff521cf326e4b05c028a28007e
username_3=ffffffff521cf326e4b05c028a28007f
username_3_g=1
username_3_g0=<ns6:UserId>ffffffff521cf326e4b05c028a28007f</ns6:UserId>
username_3_g1=ffffffff521cf326e4b05c028a28007f
username_matchNr=3
2n Question, I am trying to extract not only userId but the corresponding
Username of the UserId. So, when I have my regular expression as below:
Regular Expression:
<ns6:UserId>(.+?)</ns6:UserId>.*<ns6:UserName>(.+?)</ns6:UserName>
it is extracting the first userId and the last username. What would be the
right Reg Ex expression to extract all of them.


On Tue, Aug 27, 2013 at 5:07 PM, Flavio Cysne [via JMeter] <
ml-node+s512774n5717999h29@n5.nabble.com> wrote:

> Match number -1 return all matches under the pattern
> <variableName>_<matchIndex>_g<groupNumber>
> The total number of matches is available in <variableName>_matchNr
> variable
>
> Example: variableName = myVar
> ${myVar} will return default value or null if none was defined
> ${myVar_1_g1} will return the first match of the first group
> ${__V(myVar_${myVar_matchNr}_g1)} will return the value of the last match
> of the first group
>
>
> 2013/8/27 guru <[hidden email]<http://user/SendEmail.jtp?type=node&node=5717999&i=0>>
>
>
> > I have tried match No: -1 but it gives null. It is not extracting all
> the
> > possible matches.
> >
> > Regular
> >
> >
> Expression:<ns6:UserId>(.+?)</ns6:UserId>.*<ns6:UserName>(.+?)</ns6:UserName>
>
> > Template: $1$ $2$
> > Match No: -1
> > Default Value:
> >
> >
> >
> > --
> > View this message in context:
> >
> http://jmeter.512774.n5.nabble.com/Is-possible-extract-a-group-of-values-with-Regular-Expression-extractor-tp531174p5717997.html
> > Sent from the JMeter - User mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5717999&i=1>
> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5717999&i=2>
> >
> >
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://jmeter.512774.n5.nabble.com/Is-possible-extract-a-group-of-values-with-Regular-Expression-extractor-tp531174p5717999.html
>  To unsubscribe from Is possible extract a group of values with Regular
> Expression extractor?, click here<http://jmeter.512774.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=531174&code=cHJhdW1lc2g4NkBnbWFpbC5jb218NTMxMTc0fDEzMzMxOTQyMTg=>
> .
> NAML<http://jmeter.512774.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://jmeter.512774.n5.nabble.com/Is-possible-extract-a-group-of-values-with-Regular-Expression-extractor-tp531174p5718000.html
Sent from the JMeter - User mailing list archive at Nabble.com.

Re: Is possible extract a group of values with Regular Expression extractor?

Posted by Flavio Cysne <fl...@gmail.com>.
Match number -1 return all matches under the pattern
<variableName>_<matchIndex>_g<groupNumber>
The total number of matches is available in <variableName>_matchNr variable

Example: variableName = myVar
${myVar} will return default value or null if none was defined
${myVar_1_g1} will return the first match of the first group
${__V(myVar_${myVar_matchNr}_g1)} will return the value of the last match
of the first group


2013/8/27 guru <pr...@gmail.com>

> I have tried match No: -1 but it gives null. It is not extracting all the
> possible matches.
>
> Regular
>
> Expression:<ns6:UserId>(.+?)</ns6:UserId>.*<ns6:UserName>(.+?)</ns6:UserName>
> Template: $1$ $2$
> Match No: -1
> Default Value:
>
>
>
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/Is-possible-extract-a-group-of-values-with-Regular-Expression-extractor-tp531174p5717997.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>

Re: Is possible extract a group of values with Regular Expression extractor?

Posted by guru <pr...@gmail.com>.
I have tried match No: -1 but it gives null. It is not extracting all the
possible matches. 

Regular
Expression:<ns6:UserId>(.+?)</ns6:UserId>.*<ns6:UserName>(.+?)</ns6:UserName>
Template: $1$ $2$
Match No: -1
Default Value:



--
View this message in context: http://jmeter.512774.n5.nabble.com/Is-possible-extract-a-group-of-values-with-Regular-Expression-extractor-tp531174p5717997.html
Sent from the JMeter - User mailing list archive at Nabble.com.

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


Re: Is possible extract a group of values with Regular Expression extractor?

Posted by sebb <se...@gmail.com>.
On 01/04/2009, Jose Pablo Sarco <jo...@ar.neoris.com> wrote:
> Hi all,
>
>
>
>  I'm using Jmeter 2.3.2 on XP. I don't know if it's possible use the
>  Regular Expression extractor to extract a group of values from a
>  response.
>

Yes, see:

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Regular_Expression_Extractor

Set Match No = -1
>
>  I have this response:
>
>
>
>  <input type="checkbox" name="seleccionado" value="6001000123|6001000123"
>  checked="checked"
>  onclick="updateSelectedQuantity(this,'PrestadoresSimulacion');
>  updateState();" disabled="disabled" id="PrestadoresSimulacion_items">
>
>  <input type="checkbox" name="seleccionado" value="6091000123|6091000123"
>  checked="checked"
>  onclick="updateSelectedQuantity(this,'PrestadoresSimulacion');
>  updateState();" disabled="disabled" id="PrestadoresSimulacion_items">
>
>  <input type="checkbox" name="seleccionado" value="6901000123|6901000123"
>  checked="checked"
>  onclick="updateSelectedQuantity(this,'PrestadoresSimulacion');
>  updateState();" disabled="disabled" id="PrestadoresSimulacion_items">
>
>  ....
>
>  ....
>
>  ....
>
>  <input type="checkbox" name="seleccionado" value="7001000123|7001000123"
>  checked="checked"
>  onclick="updateSelectedQuantity(this,'PrestadoresSimulacion');
>  updateState();" disabled="disabled" id="PrestadoresSimulacion_items">
>
>
>
>  I need extract all the values:
>
>
>
>  "6001000123|6001000123"; "6091000123|6091000123";
>  "6901000123|6901000123"; ...; "7001000123|7001000123"
>
>
>
>
>
>  I have the regular expression to extract 1 of the values; but is
>  possible extract all the values with Regular Expression extractor? How?
>
>
>
>  Thanks in advance to all
>
>
>  #################################################################################################################
>  Este documento puede incluir información confidencial y propiedad de Neoris y deberá ser leído solamente por la
>  o las personas a quienes está dirigido. Si usted ha recibido este mensaje por error, por favor avise
>  inmediatamente al remitente contestando y eliminando este correo. Cualquier punto de vista u opiniones expresadas
>  en este mensaje son del remitente y no necesariamente coinciden con aquellas de Neoris. Este documento no deberá
>  ser reproducido, copiado, distribuido, publicado, ni modificado por terceros sin la autorización por escrito de Neoris.
>
>  Este mensaje ha sido verificado contra virus. Visítenos en www.neoris.com.
>  #################################################################################################################
>

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