Home > other >  Jmeter regular expression basic grammar
Jmeter regular expression basic grammar

Time:09-23

Jmeter interface after the request, if subsequent interface request to obtain the content of the return result, regular expressions extractor is required to obtain the parameters, and of course you can also use json path extractor to extract (some) this simple, but in many parts of the jmeter constraints and assertions are in need of a regular expression to match, so you still want to learn the regular expression syntax, in order to better and more efficient to complete the test content, following a brief introduction of commonly used grammar, write the first half, the next time to fill the other half, the content of the regular expression is a lot of, I also just learned some of the fur, general things, later again slowly and deeply, and to put this to use, and learn things must personally experience the actual will remember well, ok, return to forward,

I refer to the web site is deerchao.net, the author is really great, the article also is very humor, is also a senior person, ha ha, also can ignore my posts, directly study directly see Daniel's article, that I'm here directly from explained the character matching syntax for instance, you can download the site in the regular expression test tools, direct experience in tools,



The following list metacharacters grammar:

1 \ bhi \ b: matching characters, only hi \ b represents the location of the first \ b represent words starting position, the second \ b represents the position of the end of the word

2. \ bhi \ b. * \ bthis \ b: matching the hi characters, there is any characters, the back is this character

3.. : it means any character of metacharacters

4. * said: any number of metacharacters

5. \ d: any digital

6. \ d {2} : said in an arbitrary number, equivalent to a \ d \ d

7. \ s: match any whitespace characters, including Spaces, line breaks, tabs (TAB), Angle space

8. \ w: matching letters, Numbers, underscores, or Chinese characters

9. \ d + : match one or more consecutive Numbers

10. {2} \ \ b \ w b: matching have just two character words

11. \ b: match the words the beginning and end of the

12. ^ : match the start of the string

13. $: match the end of the string, example: ^ \ d {2, 5} $says the number of input must be 2 (included) to 5 (containing)

14. \ : escape character, if you want to search a metacharacter you need to complete with escape characters, such as: deerchao\.net is actually deerchao.net

15 repetitions description: * is a 0 or more times repetition, and + 1 or more times, repeated? Is a zero or one repetition, and {n} is repeated n times, {n,} is repeated n times to times, {n, m} is repeated n times to m

16. [] : the characters in the brackets will be matching, such as [ab] matching characters, a or b [?] Matches a comma or a question mark

17. [a - z0-9 a - Z] : equivalent to match \ w

18. | : match or rules, such as: 0 \ d20 \ [-] d2? \ \ d {8} | 0 d30 \ d3 [-] \ d {7} | 0 \ d {2} [-]? | 0 \ d \ d {8} {3} [-]? \ d {7} this is match the phone number, such as: 012-56236562 0536-1234567, (0536) - 1234567012234678

19. () : matching group, 255.134.123.123 or 193.168.1.1 matching expression is:

(([01]? \ d \ d? 25 [0 to 5) | | 2 \ d) \ [0-4]) {3} ([01]? \ d \ d? 25 [0 to 5) | | 2 \ [0-4] d)

20. \ W: isn't match any letters, Numbers, underscores, Chinese characters

21. \ S: don't match any whitespace characters

22. \ D: match any non-numeric characters

23. \ B: matching is not the position of the words the beginning or end

24. [^ x] : match any character other than x

25. [^ aeiou] : match any character except aeiou

26. (? \ w +) or (? 'word' \ w +) to the reference, used for repeated search in front of a group has matching text, reference can be written as \ k , in fact, grouping zero corresponds to the regular expression; Group number allocation process from left to right allocation of two times, named after the scan is not the first time the group, the second time scan named groups, so named after the grouping group number than unnamed group group number; (you can use? Participation: exp) to deprive group number distribution

27. The group is named after several grammar: (exp) the contents of a text matching, matching and exp expression automatically assigned to the group;

(? Exp) matching exp expression in the text content of the name, the name group also can be written as (? 'name' exp); (? Exp: exp) matching expression in content, but does not capture the matching text nor group number assigned to match text; (?=exp exp) matches the previous position; (? <=exp) matching position behind the exp; (? ! The position of exp) behind the match not exp; (?
28. (?=exp) with (? <=exp) zero width assertion, of which (?=exp) zero width assertion is predicted, (? <=exp) zero width assertion of backwardness is reviewed, (?=exp) said since exp assertion expression appears the location of the match before asserting content, such as \ \ w + b (?=er \ b) source files for the tester, the matching results as follows: test, (? <=exp) said since exp assertion expression content location from the end of the match at the back of the content, such as (? <=test) \ w + \ b source file for the test, the matching results as follows: er,



Half above only lists the basic regular expressions of metacharacters syntax, back to the second part of the writing,

CodePudding user response:

https://edu.csdn.net/course/detail/22948
  • Related