Turn: detailed jmeter regular Expressions (2)

Source: Internet
Author: User
Tags modifiers expression engine

For example

Reference name: Myref.

Regular expression: Name= "(. +?)" Value= "(. +?)".

Template: $1$$2$.

Do not use//encapsulate regular expressions.

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.

These variables can subsequently be referenced in the JMeter test plan, such as ${myref}, ${MYREF_G1}, and so on.

3. Key words

Regular expressions use specific characters as keywords, which have special meanings for the regular expression engine. The use of these characters in strings must be escaped (using backslashes "\") in order to treat them as primitive characters rather than as keywords for regular expressions. Here are the keywords and their meanings.

(): Combination.

[]: Character set.

{}: Duplicate.

+?: Repeat.

.: Any matching character.

\: Escape character.

| -: Selector.

^ $: The start and end of a string or line.

Note that Oro does not support \q and \e keywords.

4. Modifier (Modifier)

In theory, the modifier can be placed anywhere in the regular expression and the position being placed begins to take effect backwards. (There is a bug in Oro that the modifier cannot be placed at the end of the regular expression.) Although the modifier does not take effect here).

The single-line (? s) and MultiRow (? m) modifiers are usually placed at the beginning of the regular expression.

The Ignore (? i) modifier can be used to affect only a certain part of the regular expression, for example:

    1. Match ExAct case or (? i) arbitrary (?-i) case

Template matching behaves slightly differently because of the different settings for single-row and multiline modifiers. Note that there is no association between a single line and a multiline operator, and they can be specified separately.

1) Single-line mode

Single-line mode affects only the key character ".". By default, the "." Any character can be matched (except for line breaks). In single-line mode, "." Also matches the line break.

2) Multi-line mode

Multiline mode affects only the key characters "^" and "$". By default, "^" and "$" only match the beginning and end of a string. In multi-line mode, "^" and "$" match the beginning and end of each line.

Turn: detailed jmeter regular Expressions (2)

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.