How can i split the response of a variable


#1

I am getting my cookies in a long format JESSIONID=2334456678SHG888;path=rttt.com/backeben;secured. and i would like to split the string and save the first element as a global variable in my test. Does anyone know how i can do this.
I tried a few codes and nothing works. please see code in image


#2

Hi,

using regex you are able to get correct result

import java.util.regex.Matcher;
import java.util.regex.Pattern;

String test = "JSESSIONID=2334456678SHG888;path=rttt.com/backeben;secured";
Pattern p = Pattern.compile("JSESSIONID=([^;]+)");
Matcher m = p.matcher(test);
while(m.find()) {
     def splitted = m.group().split("=");
     System.out.println(splitted[1]);
}

2334456678SHG888