Dynamically calculate and pass value in subsequent request

I am trying to find a way to pass dynamic value in subsequent requests.

Below is my scenario:

val scn1 = exec(http("Scenario")
  .get("url with params")
  .headers(header1)
  .check(regex(mystring).findAll.saveAs("list1ofvalues"))
  .check(regex(mystring2).findAll.saveAs("list2ofvalues"))
  .resources(http("request_15")
      .get("another/request")
      .headers(headers2),

You can use below code for passing str values as.

exec(session => {
val c_list1ofvalues = session(“list1ofvalues”).as[List[String]]
val list2ofvalues = session(“list1ofvalues”).as[List[String]]
val c_list1ofvalues_count = session(“list1ofvalues_count”).as[Int]
val randomInt = ThreadLocalRandom.current.nextInt(c_list1ofvalues_count)
val str1 = c_list1ofvalues(randomInt)
val str2 = list2ofvalues(randomInt)
session.set(“str1”,str1).set(“str2”,str2)
})

Thanks G

Somehow I managed to map the values differently.
Sorry, I missed to specify 4the step in the post which is the main last step.

4 steps: