0

I tested regular expression using view result tree. It returns correct data (30 match results).

I used reference name in the regular expression extractor as regexid. Regular expression I used is \d{7} ${regexid} has value equals null. Cross checked in debug sampler. It has below info:

regexid=null regexid_g=0 regexid_g0=6104546

Why does regexid have the null value, when there were 30 matches for this regular expression?

enter image description here

Gryu
  • 2,102
  • 2
  • 16
  • 29
neha bedi
  • 146
  • 1
  • 3
  • 12

3 Answers3

1

My expectation is that you didn't put anything into "Template" field, try the following configuration:

  • Template: $1$
  • Match No: -1

As per Using RegEx (Regular Expression Extractor) With JMeter guide:

Template.

The template used to create a string from the matches found. This is an arbitrary string with special elements to refer to groups within the regular expression. The syntax to refer to a group is: '$1$' to refer to group 1, '$2$' to refer to group 2, etc. $0$ refers to whatever the entire expression matches. So, if you have in response word “economics” and search for regular expression “(ec)(onomics)” and apply template $2$$1$ than in output variable you will receive “onomicsec”.


N.B. it might be easier to use JSON Path Extractor which is available via JMeter Plugins project to deal with JSON responses

Community
  • 1
  • 1
Dmitri T
  • 159,985
  • 5
  • 83
  • 133
0

It seems like your regex is wrong as it doesn't contain return group defined.

  • When i tested the regular expression in view result tree it is returning the match results. I have attached the image of it. Regex isn't the problem i guess! – neha bedi Apr 15 '16 at 17:02
0

if you are passing -1 as match number than regexid will have the value what you have defined in your default value of regular expression extractor. If you want to use all values then you can use it by passing ${regexid_1}, ${regexid_2} and so on. Please refer below snapshotsenter image description here

Default value is notfound here

enter image description here

So link variable consist of notfound (defulat value defined in regex etractor, seems you have defined null in default value so you are getting null). rest all values are stored in refrence name appended by number

Kaushlendra Jha
  • 396
  • 1
  • 13
  • I have default defined as :Not_Found. Also **If the match number is set to a negative number, then all the possible matches in the sampler data are processed**. It doesn't set value of variable as default value , moreover it doesn't even make sense , it wouldn't be anyway solve purpose of using regular expression , as it would simply be assigning a value to a variable. – neha bedi Apr 15 '16 at 16:55