You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by rosiere <sh...@gmail.com> on 2009/11/23 15:43:26 UTC

Re: problem in reading variable set by capturing groups in regex with "Match No." set to negative

Hello,

Thanks for your explanation. 
In fact my superior only wants nothing but regular expression (and not even
XPath) so at this moment I have to figure out with his regex.


I find and also admit that I have misunderstood "refName_n_gm, where m=0,1,2
- the groups for match n " in the user's manual. n means the nst ocurrence
matched by the pattern and is not a short for "negative".

As for Debug Sampler I read some variables like these:

tgDataColumn_1_g=9 

tgDataColumn_1_g0=
19/11/2009
R0223437  
XXYYZZ Co. Ltd
778134593
PHOTOCOPIEUR
9742.66
63
T
ACCORD

tgDataColumn_1_g1=19/11/2009 
tgDataColumn_1_g2=R0223437  
tgDataColumn_1_g3=XXYYZZ Co. Ltd 
tgDataColumn_1_g4=778134593 
tgDataColumn_1_g5=PHOTOCOPIEUR 
tgDataColumn_1_g6=9742.66 
tgDataColumn_1_g7=63 
tgDataColumn_1_g8=T 
tgDataColumn_1_g9=ACCORD 

The next iterations will give something like:
tgDataColumn_2_g1=...
...
tgDataColumn_2_g9=...

But what should I do to iterate first on the different lines (occurrences)
then on the captured groups on each line?




sebb-2-2 wrote:
> 
> On 23/11/2009, rosiere <sh...@gmail.com> wrote:
>>
>>  Hello,
>>
>>  I want to parse an html <table>'s content, and create an HTTP request on
>>  each of its <tr> elements. The Http request will use some <td> element's
>>  content as its parameter, according to predefined rules. So I used a
>> regex
>>  to capture a <td>'s content as a group, on these <tr>.
>>
>>  (I did not use XPath because I'm not sure if the initial html <table>
>> and
>>  the page that contains it are well-formed.)
> 
> That's what the "Tidy" option is for.
> 
>>  This is my regular expression (say that I have only two cells in each
>> wanted
>>  tr. The cell's class must be  "tgDataColumn", and I want to capture
>> their
>>  content):
>>
>>  <TD
>> 
>> class=(?:\"tgDataColumn\"|tgDataColumn)(?:.*index=[\d+]\'\">)(.*)</TD>\n<TD
>>  class=(?:\"tgDataColumn\"|tgDataColumn)(?:.*index=[\d+]\'\">)(.*)</TD>\n
> 
> No need to prefix " and ' with \ as they are not meta-characters.
> Is TD upper case always?
> 
> \n can be problematic in REs.
> 
>>
>>
>>
>>  I will use it to capture all occurrences (all <tr> that contains
>>  "class=tgDataColumn" or "class="tgDataColumn"") in a HTML, then, in a
>>  foreach controller whose "Input variable prefix" is set to "myRef" (the
>>  "Reference Name" of my regex extrazctor), I want to reference to
>> variables
>>  created by regex, with:
>>  "myRef_n_gm" syntax. I created a Http sampler, that uses each group
>>  ${myRef_n_gm}'s value  as a parameter.
>>
>>  However under my foreach controller, I'm unable to find these myRef_n_gm
>>  variables' value, and at last they are represented like literals:
>>  "${myRef_n_g0}", "${myRef_n_g1}", etc...
>>
>>  The only thing I can do is capture the td's content and write it into a
>>  template of regex extractor - A=$1$&B=$2$, then use the concatenated
>>  template value  (like "A=xx&B=yy") as a whole, in my foreach controller.
>>
>>
>>  What did I miss?
> 
> What does the source page look like?
> 
> Have you tried using the  ORO demo page to test the RE?
> 
> http://jakarta.apache.org/oro/demo.html
> 
> Use the Debug Sampler + View Results Tree to see what variables have
> been defined.
> 
> But XPath is going to be much easier to use.
> 
>>
>>
>>  --
>>  View this message in context:
>> http://old.nabble.com/problem-in-reading-variable-set-by-capturing-groups-in-regex-with-%22Match-No.%22-set-to-negative-tp26475373p26475373.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
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/problem-in-reading-variable-set-by-capturing-groups-in-regex-with-%22Match-No.%22-set-to-negative-tp26475373p26479294.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: problem in reading variable set by capturing groups in regex with "Match No." set to negative

Posted by rosiere <sh...@gmail.com>.
Hello,

As for iteration, I read these from Debug sampler's out put:
tgDataColumn_1_g=9

tgDataColumn_1_g0=
19/11/2009
R0223437 
XXYYZZ Co. Ltd
778134593
PHOTOCOPIEUR
9742.66
63
T
ACCORD

tgDataColumn_1_g1=19/11/2009
tgDataColumn_1_g2=R0223437 
tgDataColumn_1_g3=XXYYZZ Co. Ltd
tgDataColumn_1_g4=778134593
tgDataColumn_1_g5=PHOTOCOPIEUR
tgDataColumn_1_g6=9742.66
tgDataColumn_1_g7=63
tgDataColumn_1_g8=T
tgDataColumn_1_g9=ACCORD 

Which means that the first occurrence matched by regex will create variables
named "tgDataColumn_1_g..", the second will create "tgDataColumn_2_g..", and
so on.

Now I want to find the syntax to iterate each occurrence i, from,
tgDataColumn_i_g1 to tgDataColumn_i_g9, so that I will be able to create an
Http request on each occurrence, with 9 parameters, each parameter taking a
captured group (from g1 to g9).

However I cannot find such an explanation in ForEach Controller's paragraph,
in the user manual (or I haven't fully understood it).

So what is the syntax for iterating on the "i"st occurrence?


sebb-2-2 wrote:
> 
> On 23/11/2009, rosiere <sh...@gmail.com> wrote:
>>
>>  Hello,
>>
>>  Thanks for your explanation.
>>  In fact my superior only wants nothing but regular expression (and not
>> even
>>  XPath) so at this moment I have to figure out with his regex.
> 
> "Did they give a reason?"
> 
> "He just spent a lot of time on regex and found it more acceptable than
> other solutions. I also talked about XPath but he didn't seem interested
> in it."
> 
>>  I find and also admit that I have misunderstood "refName_n_gm, where
>> m=0,1,2
>>  - the groups for match n " in the user's manual. n means the nst
>> ocurrence
>>  matched by the pattern and is not a short for "negative".
>>
>>  As for Debug Sampler I read some variables like these:
>>
>>  tgDataColumn_1_g=9
>>
>>  tgDataColumn_1_g0=
>>  19/11/2009
>>  R0223437
>>  XXYYZZ Co. Ltd
>>  778134593
>>  PHOTOCOPIEUR
>>  9742.66
>>  63
>>  T
>>  ACCORD
>>
>>  tgDataColumn_1_g1=19/11/2009
>>  tgDataColumn_1_g2=R0223437
>>  tgDataColumn_1_g3=XXYYZZ Co. Ltd
>>  tgDataColumn_1_g4=778134593
>>  tgDataColumn_1_g5=PHOTOCOPIEUR
>>  tgDataColumn_1_g6=9742.66
>>  tgDataColumn_1_g7=63
>>  tgDataColumn_1_g8=T
>>  tgDataColumn_1_g9=ACCORD
>>
>>  The next iterations will give something like:
>>  tgDataColumn_2_g1=...
>>  ...
>>  tgDataColumn_2_g9=...
>>
>>  But what should I do to iterate first on the different lines
>> (occurrences)
>>  then on the captured groups on each line?
>>
> 
> Not sure I understand what the last sentence means.
> 
> The normal way to use groups of variables is the For Each Controller:
> 
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#ForEach_Controller
> 
>>
>>
>>
>>  sebb-2-2 wrote:
>>  >
>>  > On 23/11/2009, rosiere <sh...@gmail.com> wrote:
>>  >>
>>  >>  Hello,
>>  >>
>>  >>  I want to parse an html <table>'s content, and create an HTTP
>> request on
>>  >>  each of its <tr> elements. The Http request will use some <td>
>> element's
>>  >>  content as its parameter, according to predefined rules. So I used a
>>  >> regex
>>  >>  to capture a <td>'s content as a group, on these <tr>.
>>  >>
>>  >>  (I did not use XPath because I'm not sure if the initial html
>> <table>
>>  >> and
>>  >>  the page that contains it are well-formed.)
>>  >
>>  > That's what the "Tidy" option is for.
>>  >
>>  >>  This is my regular expression (say that I have only two cells in
>> each
>>  >> wanted
>>  >>  tr. The cell's class must be  "tgDataColumn", and I want to capture
>>  >> their
>>  >>  content):
>>  >>
>>  >>  <TD
>>  >>
>>  >>
>> class=(?:\"tgDataColumn\"|tgDataColumn)(?:.*index=[\d+]\'\">)(.*)</TD>\n<TD
>>  >> 
>> class=(?:\"tgDataColumn\"|tgDataColumn)(?:.*index=[\d+]\'\">)(.*)</TD>\n
>>  >
>>  > No need to prefix " and ' with \ as they are not meta-characters.
>>  > Is TD upper case always?
>>  >
>>  > \n can be problematic in REs.
>>  >
>>  >>
>>  >>
>>  >>
>>  >>  I will use it to capture all occurrences (all <tr> that contains
>>  >>  "class=tgDataColumn" or "class="tgDataColumn"") in a HTML, then, in
>> a
>>  >>  foreach controller whose "Input variable prefix" is set to "myRef"
>> (the
>>  >>  "Reference Name" of my regex extrazctor), I want to reference to
>>  >> variables
>>  >>  created by regex, with:
>>  >>  "myRef_n_gm" syntax. I created a Http sampler, that uses each group
>>  >>  ${myRef_n_gm}'s value  as a parameter.
>>  >>
>>  >>  However under my foreach controller, I'm unable to find these
>> myRef_n_gm
>>  >>  variables' value, and at last they are represented like literals:
>>  >>  "${myRef_n_g0}", "${myRef_n_g1}", etc...
>>  >>
>>  >>  The only thing I can do is capture the td's content and write it
>> into a
>>  >>  template of regex extractor - A=$1$&B=$2$, then use the concatenated
>>  >>  template value  (like "A=xx&B=yy") as a whole, in my foreach
>> controller.
>>  >>
>>  >>
>>  >>  What did I miss?
>>  >
>>  > What does the source page look like?
>>  >
>>  > Have you tried using the  ORO demo page to test the RE?
>>  >
>>  > http://jakarta.apache.org/oro/demo.html
>>  >
>>  > Use the Debug Sampler + View Results Tree to see what variables have
>>  > been defined.
>>  >
>>  > But XPath is going to be much easier to use.
>>  >
>>  >>
>>  >>
>>  >>  --
>>  >>  View this message in context:
>>  >>
>> http://old.nabble.com/problem-in-reading-variable-set-by-capturing-groups-in-regex-with-%22Match-No.%22-set-to-negative-tp26475373p26475373.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
>>  >
>>  >
>>  >
>>
>>
>> --
>>  View this message in context:
>> http://old.nabble.com/problem-in-reading-variable-set-by-capturing-groups-in-regex-with-%22Match-No.%22-set-to-negative-tp26475373p26479294.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
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/problem-in-reading-variable-set-by-capturing-groups-in-regex-with-%22Match-No.%22-set-to-negative-tp26475373p26480216.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: problem in reading variable set by capturing groups in regex with "Match No." set to negative

Posted by sebb <se...@gmail.com>.
On 23/11/2009, rosiere <sh...@gmail.com> wrote:
>
>  Hello,
>
>  Thanks for your explanation.
>  In fact my superior only wants nothing but regular expression (and not even
>  XPath) so at this moment I have to figure out with his regex.

Did they give a reason?

>  I find and also admit that I have misunderstood "refName_n_gm, where m=0,1,2
>  - the groups for match n " in the user's manual. n means the nst ocurrence
>  matched by the pattern and is not a short for "negative".
>
>  As for Debug Sampler I read some variables like these:
>
>  tgDataColumn_1_g=9
>
>  tgDataColumn_1_g0=
>  19/11/2009
>  R0223437
>  XXYYZZ Co. Ltd
>  778134593
>  PHOTOCOPIEUR
>  9742.66
>  63
>  T
>  ACCORD
>
>  tgDataColumn_1_g1=19/11/2009
>  tgDataColumn_1_g2=R0223437
>  tgDataColumn_1_g3=XXYYZZ Co. Ltd
>  tgDataColumn_1_g4=778134593
>  tgDataColumn_1_g5=PHOTOCOPIEUR
>  tgDataColumn_1_g6=9742.66
>  tgDataColumn_1_g7=63
>  tgDataColumn_1_g8=T
>  tgDataColumn_1_g9=ACCORD
>
>  The next iterations will give something like:
>  tgDataColumn_2_g1=...
>  ...
>  tgDataColumn_2_g9=...
>
>  But what should I do to iterate first on the different lines (occurrences)
>  then on the captured groups on each line?
>

Not sure I understand what the last sentence means.

The normal way to use groups of variables is the For Each Controller:

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

>
>
>
>  sebb-2-2 wrote:
>  >
>  > On 23/11/2009, rosiere <sh...@gmail.com> wrote:
>  >>
>  >>  Hello,
>  >>
>  >>  I want to parse an html <table>'s content, and create an HTTP request on
>  >>  each of its <tr> elements. The Http request will use some <td> element's
>  >>  content as its parameter, according to predefined rules. So I used a
>  >> regex
>  >>  to capture a <td>'s content as a group, on these <tr>.
>  >>
>  >>  (I did not use XPath because I'm not sure if the initial html <table>
>  >> and
>  >>  the page that contains it are well-formed.)
>  >
>  > That's what the "Tidy" option is for.
>  >
>  >>  This is my regular expression (say that I have only two cells in each
>  >> wanted
>  >>  tr. The cell's class must be  "tgDataColumn", and I want to capture
>  >> their
>  >>  content):
>  >>
>  >>  <TD
>  >>
>  >> class=(?:\"tgDataColumn\"|tgDataColumn)(?:.*index=[\d+]\'\">)(.*)</TD>\n<TD
>  >>  class=(?:\"tgDataColumn\"|tgDataColumn)(?:.*index=[\d+]\'\">)(.*)</TD>\n
>  >
>  > No need to prefix " and ' with \ as they are not meta-characters.
>  > Is TD upper case always?
>  >
>  > \n can be problematic in REs.
>  >
>  >>
>  >>
>  >>
>  >>  I will use it to capture all occurrences (all <tr> that contains
>  >>  "class=tgDataColumn" or "class="tgDataColumn"") in a HTML, then, in a
>  >>  foreach controller whose "Input variable prefix" is set to "myRef" (the
>  >>  "Reference Name" of my regex extrazctor), I want to reference to
>  >> variables
>  >>  created by regex, with:
>  >>  "myRef_n_gm" syntax. I created a Http sampler, that uses each group
>  >>  ${myRef_n_gm}'s value  as a parameter.
>  >>
>  >>  However under my foreach controller, I'm unable to find these myRef_n_gm
>  >>  variables' value, and at last they are represented like literals:
>  >>  "${myRef_n_g0}", "${myRef_n_g1}", etc...
>  >>
>  >>  The only thing I can do is capture the td's content and write it into a
>  >>  template of regex extractor - A=$1$&B=$2$, then use the concatenated
>  >>  template value  (like "A=xx&B=yy") as a whole, in my foreach controller.
>  >>
>  >>
>  >>  What did I miss?
>  >
>  > What does the source page look like?
>  >
>  > Have you tried using the  ORO demo page to test the RE?
>  >
>  > http://jakarta.apache.org/oro/demo.html
>  >
>  > Use the Debug Sampler + View Results Tree to see what variables have
>  > been defined.
>  >
>  > But XPath is going to be much easier to use.
>  >
>  >>
>  >>
>  >>  --
>  >>  View this message in context:
>  >> http://old.nabble.com/problem-in-reading-variable-set-by-capturing-groups-in-regex-with-%22Match-No.%22-set-to-negative-tp26475373p26475373.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
>  >
>  >
>  >
>
>
> --
>  View this message in context: http://old.nabble.com/problem-in-reading-variable-set-by-capturing-groups-in-regex-with-%22Match-No.%22-set-to-negative-tp26475373p26479294.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