0
votes

I think I have an issue on JMeter.
Consider the following scenario :

Controller
    User defined variables (I define here a variable named var="12345")
    Regular Expression Extractor (in which I define a new variable var2 which will contain the 4 first characters of var, so var2="1234")
    BeanShell Sampler (I've just put log.info("my var2 is " + vars.get("var2"))

The expected result is to print the value of var2. Unfortunately, I got null instead of "1234".
If I put a "Debug Sampler" just after the "Regular Expression Extractor", it works fine.
Is there something I've missed ?

1
Can you please post what is in your extractor configuration?RaGe

1 Answers

0
votes

If you're trying to use Regular Expression Extractor to extract first 4 digits from a User Defined Variable, apply the following configuration:

  • Apply to: Jmeter Variable - var
  • Reference Name: var2
  • Regular Expression: (\d\d\d\d)
  • Tempalte: $1$

Also make sure that you add Regular Expression Extractor after or (better) as a child of a sampler as it it a PostProcessor, and if the PostProcessor doesn't have parent or preceding sampler - it just won't work at all.

Regex

Above configuration should work fine.

See Using RegEx (Regular Expression Extractor) with JMeter guide for advanced information on extracting data using regular expressions in JMeter.