0

I have a regular expression with the Reference Name: ${id}. I want to create another regular expression and I was wondering if I can use the above reg ex reference name.

Here is the reg exp I am trying to create:

<a href=\\"/([^"]+?)/e\?retURL=%2F${id}\\"    

Currently when I run my script the above regular expression doesn't return a value.

The above regular expression works fine if use the id value as follows:

<a href=\\"/([^"]+?)/e\?retURL=%2F801000000092838\\"    

But instead of using the actual id value (801000000092838) I want it to run with the reg exp name ${id} to pull the value dynamically.

Adriano
  • 3,788
  • 5
  • 32
  • 53
Kumar
  • 51
  • 1
  • 6
  • This might help: https://stackoverflow.com/questions/16715437/jmeter-regex-in-beanshell-matcher-pattern-is-cutting-national-character You might want to define your `pattern` as a string, and then run the regex for every value you pass to it, by dynamically change the `pattern` you pass to the regex. – Adriano Aug 01 '18 at 00:36

1 Answers1

0

You should be able to do this, I cannot reproduce your problem using latest JMeter 4.0, I have:

  1. Defined a User Variable id with the value of 801000000092838 on Test Plan level
  2. Response data: <a href="http://example.com/e?retURL=%2F801000000092838"
  3. Regular Expression: <a href="(.+?)/e\?retURL=%2F${id}"
  4. I'm able to see http://example.com using Debug Sampler and View Results Tree listener combination

    JMeter use variable in the regular expression

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Thanks, Dmitri. I have defined the regular expression id with the value of 801000000092838 on the Thread Group level in one of the HTTP requests and defined another regular regular expression in the next HTTP request with the name newid as: – Kumar Aug 01 '18 at 06:29