-2

I use jMeter 5.5-Snapshot 3a74a92. I need to use result of previous Regular Expression Extractor stored in variable in next Regular Expression Extractor when both Regular Expression Extractors are under same HTTP Request. The example of fixed regexp that matches the result is:

<input type=\\"hidden\\" id=\\"def_SomeString\\" value=\\"(.*?)\\"/>

but 'SomeString' is something that is matched by previous Regular Expression Extractor and I have to use variable here. After several tries and analyzing debug output (that can be enabled by putting focus on Regular Expression Extractor then About->Enable Debug, do not forget to disable it later) I found that below regexp properly interprets variable and substitutes it:

<input type=\\\\"hidden\\\\" id=\\\\"def_${myVar}\\\\" value=\\\\"(.*?)\\\\"/>

Why in second expression with variable used all backslashes must be extra escaped in such weird way to match? Looks like using variable requires to use '\\\\"' to match '\"' which is unclear for me. Where in the documentation description of such usage can be found? I can't see anything about it there.

E_net4
  • 27,810
  • 13
  • 101
  • 139
user1337
  • 175
  • 7

1 Answers1

1

I don't think you need to have these extra escape backslashes in the 2nd regular expression.

I also don't think that using regular expressions for parsing HTML is a good idea, consider using CSS Selector Extractor instead.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • As I wrote in the question I had checked and confirmed practically that those extra escape backslashes are required when variable name is used in the reqexp. Regardless of reasonability of regexp usage in this particular case the question was why those extra escape backslashes are required when variable is used and where in the documentation this is described. – user1337 May 04 '22 at 20:01
  • Anyway because of your advice I switched from regexp to JSON and CSS Extractors that makes implementation more efficient and easier to maintain. Thanks. – user1337 May 04 '22 at 20:02