[2 methods, jmeter uses a regular extractor to extract multiple values! 】

In jmeter, use the json extractor to extract multiple values ​​at one time. Many people know this. However, is it possible to use a regular extractor to extract multiple items at once?

Certainly, many people confidently say, yes! In the form: token":"(.*?)","identity":"(.*?)" If you write a regular expression like this, you can extract two!

Yes, there is nothing wrong with this approach, but do you find a problem?

How should you fill in your "Name of created variable reference name"?

Do you fill in one or multiple entries? What symbols do you use to separate multiple entries?

Then, you are stunned, because you cannot use a regular extractor to write multiple extracted values ​​​​to corresponding variables at the same time. Although you ideally write multiple variable names, they are also separated by symbols.

As a result, when you use the debug sampler to view it, you find that the multiple values ​​​​you took are all in one variable, and this variable has a symbol.

picture

picture

what? Can't extract more than one at a time? So if I want to use more than one, how should I use them?

Here, I will tell you two methods:

method one

If you have sharp eyes, you may have seen the light from the picture above.

In the previous picture, we have retoken,iden_g1 and retoken,iden_g2, see? Are their values ​​what you want?

Therefore, we can extract multiple values ​​​​at the same time in a regular extractor. When there are multiple values, there is no need to separate the symbols between the templates. Use a variable to receive them, and then use the variable name _g1 and variable name _g2 when using them in association. ...and so on, that's it.

picture

picture

picture

picture

Method Two

Since a variable is used to receive it, it will receive all the extracted values, so I will split the values. Split into multiple values ​​using a defined punctuation mark.

Write multiple regular expressions, use 1 variable to receive them, and  separate the templates with commas 

picture

Use a split function to split it and put it into new variables

picture

From the debug sampler, you can see the results after splitting

picture

Use a new variable name. Note that if you use the first variable, use the new variable name_1

picture

Finally, when requesting, in the view result tree, you can see that the result of the request has already used the split value.

picture

Okay, have you got both methods?

Guess you like

Origin blog.csdn.net/m0_58552717/article/details/132081070