如何从此ResponseHeader中提取JSESSIONID(' ='之前的所有内容?''?
Set-Cookie:Apache=40.76.87.14.1462996905538733; path=/; domain=.cra-arc.gc.ca,JSESSIONID=KjahaS5VdMBttn9bAYuS_iHFXOgmqQyMxHcht1kBS7p1YOpdV2V_!1094217526; path=/; HttpOnly
答案 0 :(得分:3)
您可以使用:
/JSESSIONID=(.*?);/
Regex101演示:
https://regex101.com/r/nH4mT0/1
正则表达式说明:
JSESSIONID=(.*?);
Match the character string “JSESSIONID=” literally (case sensitive) «JSESSIONID=»
Match the regex below and capture its match into backreference number 1 «(.*?)»
Match any single character that is NOT a line break character (line feed, carriage return, line separator, paragraph separator) «.*?»
Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
Match the character “;” literally «;»
答案 1 :(得分:1)
您可以使用此模式:
/JSESSIONID=([^;]*)/
解释上面的正则表达式:
JSESSIONID= # match the text literally
( # asserts that all content inside it will be in group $1
[^;] # means any character not ';'
* # as many as possible
) # end of the group $1
您想要的值将在第1组内。
您可以在action here中看到它。