3.7.3-Java - regex({"access_token":"(.*)",).find.transform.exists extraction crashed: transform crashed: j.u.r.PatternSyntaxException: Illegal repetition near index 1

Hello All,

Getting an exception during extraction of a string in a redirected response. Following is the Java code and the log message. Not able to proceed, require help.

.exec(
http(“request_33”)
.post(uri2 + “/tenant/” + “#{tenant}” + “/login”)
.headers(headers_31)
.formParam(“otdscsrf”, “#{otdscsrf}”)
.formParam(“fragment”, “”)
.formParam(“RFA”, “#{rfa}”)
.formParam(“otds_username”, “test1”)
.formParam(“otds_password”, “Password”)
.check(
regex("{“access_token”:"(.*)",").saveAs(“token1”)
)
)


body:
{“access_token”:“eyJraWQiOiJkZjY5YTc5M2I2NWU2Njk1ZGMzMzJmYjM0OWUwMDMwMTE0NjJlNzM0IiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiI3N2VhMmRmYi04MzQxLTQxMmQtYmM4Mi0xNmU2ZDQxMGY1MTAiLCJzY3AiOlsic2VhcmNoIiwiY3JlYXRlX3B1YmxpY2F0aW9ucyIsInZpZXdfcHVibGljYXRpb25zIiwic3Vic2NyaXB0aW9uOmNjcDIxM3N1YiIsInJncGFydGl0aW9uOm90ZHMuYWRtaW4iLCJyZ3BhcnRpdGlvbjoxNjBhNWI3Zi1jZjk3LTQxYTctYTBiMC1kZWU0N2Y5ZGM2Y2YiLCJ2aWV3X2FueV9wdWJsaWNhdGlvbiIsInJncGFydGl0aW9uOjhjN2Q0MjdkLTcyNDMtNDFjMi1iYmVhLTZkOTY4YTMzNmVlMSJdLCJkbXAiOnsiT1REU19DUkVEU19BVVRIIjoidHJ1ZSIsIk9URFNfSEFTX1BBU1NXT1JEIjoidHJ1ZSJ9LCJydGkiOiJkZDFiNzVhZS04MDc3LTRkNzEtYmFmZi0zMzY5YTZiMTA2Y2YiLCJzYXQiOjE2NDIxMDMwMTMsImlzcyI6Imh0dHBzOi8vb3Rkc2F1dGgtY2NwMjEzLnBlcmYtb3QyLWVudjMucGVyZmxhYi5vcG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CI6MTY0MjEwMzAxNCwianRpIjoiZGQxYjc1YWUtODA3Ny00ZDcxLWJhZmYtMzM2OWE2YjEwNmNmIiwiY2lkIjoiZDNlMzU0NzUtMzhmMy00ZDYxLTk3NWItMzFkODM2NzVjMzY3In0.OnyFZplnzlOZrRvLdWe_eAk1IL2b4Uc2VYxlo2ZE8q4_KgNvipwB89i7r-F9DTzRebSLk85OBFv7s0ZA-8B_Rb2XEzl2aTAeeAZtlS3I4WA1HcBbnEPzTXOgyDaoBlP5IM6eQkj5ObHVJat93uY2jdbio6nrKAGAMZQ42c5cgrC8HO957LnVPoQXg8uyCtC5E5TPRqXAdZmOyk5i_is7_B2XIZEJLSOU7AzXiPRkX0mijlYgorNSfo4sx42fE16S3ceHjDKp4wddLGwmEgnJueFTnABe8i0f1nyq6AiqfWMLrJ364e9ay1VfXZDabYAdEZQwHPu_wV4ubFfRVjQWcQ”,“expires_in”:1199}
<<<<<<<<<<<<<<<<<<<<<<<<<
01:13:34.495 [DEBUG] i.g.h.e.r.DefaultStatsProcessor - Request ‘request_33 Redirect 2’ failed for user 1: regex({“access_token”:"(.)",).find.transform.exists extraction crashed: transform crashed: j.u.r.PatternSyntaxException: Illegal repetition near index 1
{“access_token”:"(.
)",
^
01:13:34.497 [TRACE] i.g.h.e.r.DefaultStatsProcessor -

Request:
request_33 Redirect 2: KO regex({“access_token”:"(.)",).find.transform.exists extraction crashed: transform crashed: j.u.r.PatternSyntaxException: Illegal repetition near index 1
{“access_token”:"(.
)",
^

The error is very explicit:

j.u.r.PatternSyntaxException: Illegal repetition near index 1
{“access_token”:"(.*)",
^

It tells you your pattern is malformed and the error is near index 1. Indeed, { (curly brace) is a reserved character, see https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html, so it has to be escaped with a backslash.

Then, why use regex for parsing JSON and not JMESPath or JsonPath?

Thank you for the clarification.