0
votes

I have extracted a string from the HTML response body using the below REGEX code

.check(regex("pzTransactionId=.*pzFromFrame").find.saveAs("pzTransId"))

Extracted value is pzTransactionId=1g2h3j1h2g35k6j4lnx93jsn83jsn1e&pzFromFrame

But I need a substring from the extracted value which is g2h3j1h2g35k6j4lnx93jsn83jsn1e. How do I do that? I need this value so that I can pass it in subsequent request. I tried the below options but it did not work.

.exec{session
val pztransactionid = (session("pzTransId").as[String].substring(0,5))}

But if I print pztransactionid it says value is not available in the session.

1

1 Answers

0
votes

Your regex is wrong, it should be:

.check(regex(".*pzTransactionId=(.*)&pzFromFrame.*").find.saveAs("pzTransId"))

I recommend you read Java regex documentation, in particular capture groups.