Jmeter Association. The regular expression extractor uses 1

Source: Internet
Author: User
 

I. jmeter association method:

In jmeter, you can right-click the request to obtain data --> the post-processor selects the desired association method. If there are many ways to extract dynamic data:

  

 

Ii. Regular Expression Extraction Tool:

1. For example, if you need to extract "<title> Baidu" from the following response text, you will know "Baidu" in </title> ":

  

2. Set the regular expression extractor:

  

Note:

  (1) Reference name: name of the parameter to be referenced in the next request. If you enter the title, you can reference it with $ {Title.

(2) regular expression:

(): The included parts are extracted.

.: Match any string. +: One or more times. ? : Don't be greedy. Stop after finding the first match.

(3) template: referenced with $. If there are multiple regular expressions in the regular expression, it can be $2 $3 $, etc, indicates the number of parsed values to the title. For example, $1 $ indicates the parsed 1st values.

(4) matching number: 0 indicates a random value. 1 indicates all values. Normally, enter 0.

(5) Default Value: If the parameter has not obtained a value, it is given a value by default.

 

3. Use the value obtained in 2:

  

 

Iii. Examples of Regular Expressions:

1. Extract A single string:
If you want to match the following parts of the web page: Name = "file" value = "readme.txt"> and extract readme.txt. A suitable regular expression: Name = "file" value = "(. + ?) ">.
(): Encapsulates the matching string to be returned.
.: Match any single string.
+: One or more times.
? : Don't be greedy. Stop after finding the first match.

2. Extract multiple strings:
If you want to match the following parts of the web page: Name = "file. Name" value = "readme.txt"> and extract file.nameand readme.txt. A suitable regular expression: Name = "(. + ?) "Value =" (. + ?) ". In this way, two groups are created for $1 $ and $2 $ respectively.

For example:

Reference name: myref
Template: $1 $2 $

The values of the following variables will be set:
Myref: file.namereadme.txt
Myref_g0: Name = "file. Name" value = "readme.txt"
Myref_g1: file. Name
Myref_g2: readme.txt

You can use $ {myref} and ${myref_g1 for reference.

Jmeter Association. The regular expression extractor uses 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.