0

I'm trying to escape some characters in a string. The string is constantly changing, for example Set-Cookie: SESSION=60a8245bc1976b40d0d8c4ff6f9784fc; path=/ I want to remove Set-Cookie: SESSION= and ; path=/ to leave 60a8245bc1976b40d0d8c4ff6f9784fc. But since it has "complex" characters, like : = / returns an error when i try

SET cookies2=%cookies:Set-Cookie: SESSION=%
SET cookies3=%cookies2:; path=/=%
echo %cookies3%

1 Answer 1

1

use a for /f loop to split the string:

@echo off
set "string=Set-Cookie: SESSION=60a8245bc1976b40d0d8c4ff6f9784fc; path=/"
set string
for /f "tokens=2 delims==;" %%a in ("%string%") do set "var=%%a"
echo -%var%-
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.