Need help on regex for correlation purpose in Gatling.

I do have scenario where I need to extract a dynamic value from the post request for correlation purpose and here is what it looks like

Here I am trying to extract the dynamic value which is YTttA from the post request

post(uri3 + “/as/YTttA/resume/as/Session.id”)

Here is what my Regex looks like

Regex :- check(regex(as="([^"]+)").saveAS(“SessionID”))

Can some please let me know whether the regex format is good and is there any other way to handle this in Gatling

Can some one please help me out ?

It would help to check the gatling implementation under the hood https://github.com/gatling/gatling

then take that regex code in the gatling api that does regex , in a driver program and test it out.

Danny,

I have no luck doing correlations even after reading the doucmentation I am really looking to learn Gatling tool but not able to understand the concepts how it works ? if some one want to help please provide some sample or example scritps with basic things like parameterization, correlation, error checks, etc.,

In my Gatling script I use the following, there are probably more elegant regex’s to use but I did this in a rush

.exec(http(“request_5”)
.post("/app/login")
.headers(headers_5).check(header(“Set-Cookie”).saveAs(“MyAppCookie”))
.body(RawFileBody(“App_0005_request.txt”)).check(regex(".?“guid”:"(.?)".*").saveAs(“MyAppSessionKey”)))

.exec(http(“request_5_1”)
.post("/app/${MyAppSessionKey}/subscribe")
.headers(headers_6).header(“Cookie”,"${MyAppCookie}")

Gatling I believe uses the same RegExp syntax as Scala/Java, see e.g. https://www.tutorialspoint.com/scala/scala_regular_expressions.htm
I use e.g. https://www.freeformatter.com/java-regex-tester.html to test my regexp is correct before editing and running my Gatling simulation.
Thanks,
Dave.

If your string is literally as you have posted there (i.e. “”/as/YTttA/resume/as/Session.id") then this regex works .?/as/(.?)/.*