Regular Expression

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Regular Expression

Puneet Varma
I have used the following regular expression for the value
2C94854D656354990165E824FA460175  with the regular expression
value="(.+?)" />

it is not working.  it is a check box, Id changes every time I am running
it.

Any help is greatly appreciate it.
Reply | Threaded
Open this post in threaded view
|

Re: Regular Expression

shettyd
Hi
you havent posted the text you are matching against so cant say why your
regex isnt working
Generally expressions like the above fail because . You have whitespace ,
or you are using a single quote or there is something between value and the
end of your tag like a css class and so on. Check the text of the response
and ensure that your regex is a child of the sampler returning the response

regards
deepak

On Mon, Sep 17, 2018 at 8:34 AM Puneet Varma <[hidden email]> wrote:

> I have used the following regular expression for the value
> 2C94854D656354990165E824FA460175  with the regular expression
> value="(.+?)" />
>
> it is not working.  it is a check box, Id changes every time I am running
> it.
>
> Any help is greatly appreciate it.
>
Reply | Threaded
Open this post in threaded view
|

Re: Regular Expression

Puneet Varma
Thanks for the response. Below is what I have for the checkbox.


<input id="sg:cf:b:0" type="checkbox" name="sg:cf:b" checked="checked"
value="2C94854D656354990165E824FA460175" int-ns-multiple="sgcfb">

On Mon, Sep 17, 2018 at 12:50 PM Deepak Shetty <[hidden email]> wrote:

> Hi
> you havent posted the text you are matching against so cant say why your
> regex isnt working
> Generally expressions like the above fail because . You have whitespace ,
> or you are using a single quote or there is something between value and the
> end of your tag like a css class and so on. Check the text of the response
> and ensure that your regex is a child of the sampler returning the response
>
> regards
> deepak
>
> On Mon, Sep 17, 2018 at 8:34 AM Puneet Varma <[hidden email]>
> wrote:
>
> > I have used the following regular expression for the value
> > 2C94854D656354990165E824FA460175  with the regular expression
> > value="(.+?)" />
> >
> > it is not working.  it is a check box, Id changes every time I am running
> > it.
> >
> > Any help is greatly appreciate it.
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Regular Expression

shettyd
Hi
name=" sg:cf:b"\s+checked="checked"\s+value="([^"]+)" should work - The
reason you have to add the name is because there are likely other html
elements. Its upto you if you want to retain the checked part (will break
whenever your html changes slightly) v/s a more generic .+? which is
inefficient. If you are willing to give up some efficiency and memory ,the
XPath selectors usually work better for HTML elements (in the sense of
easier to read and logical in how they deal with attributes)

Your original expression had   /> which is not in your text , so it would
not have worked (As well as you are likely to have matched some other value.


regards
deepak

On Mon, Sep 17, 2018 at 10:05 AM Puneet Varma <[hidden email]>
wrote:

> Thanks for the response. Below is what I have for the checkbox.
>
>
> <input id="sg:cf:b:0" type="checkbox" name="sg:cf:b" checked="checked"
> value="2C94854D656354990165E824FA460175" int-ns-multiple="sgcfb">
>
> On Mon, Sep 17, 2018 at 12:50 PM Deepak Shetty <[hidden email]> wrote:
>
> > Hi
> > you havent posted the text you are matching against so cant say why your
> > regex isnt working
> > Generally expressions like the above fail because . You have whitespace ,
> > or you are using a single quote or there is something between value and
> the
> > end of your tag like a css class and so on. Check the text of the
> response
> > and ensure that your regex is a child of the sampler returning the
> response
> >
> > regards
> > deepak
> >
> > On Mon, Sep 17, 2018 at 8:34 AM Puneet Varma <[hidden email]>
> > wrote:
> >
> > > I have used the following regular expression for the value
> > > 2C94854D656354990165E824FA460175  with the regular expression
> > > value="(.+?)" />
> > >
> > > it is not working.  it is a check box, Id changes every time I am
> running
> > > it.
> > >
> > > Any help is greatly appreciate it.
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Regular Expression

glinius@live.com
In reply to this post by Puneet Varma
Mind that  using Regular Expressions for HTML response types might be not the
best idea <https://stackoverflow.com/a/1732454/2897748>   as regular
expressions are hard to develop/maintain/understand, they are fragile, they
are sensitive to markup changes (i.e. if order of attributes changes or
there will be a line break - it will run your regex).

So consider going for  CSS/JQuery Extractor
<http://jmeter.apache.org/usermanual/component_reference.html#CSS/JQuery_Extractor>  
instead, the configuration would be as simple as:

CSS Selection Expression:* input[id=sg:cf:b:0]*
Attribute: *value*

Demo:

<http://www.jmeter-archive.org/file/t340375/Screen_Shot_2018-09-20_at_16.png>

More information:  How to Use the CSS/JQuery Extractor in JMeter
<https://www.blazemeter.com/blog/how-use-cssjquery-extractor-jmeter>  



--
Sent from: http://www.jmeter-archive.org/JMeter-User-f512775.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]