I am working on a batch file that receives data as a variable, and in this variable has an exclamation mark.
What I'm trying to do is add the necessary escape characters to the variable.
"Title":"Turk 182!"
The above is an example of the data I'm working with.
setlocal EnableDelayedExpansion rem replace ! with ^^! set var=%var:!=^^!!%
But I'm not sure if this is the correct syntax, so how can I avoid the esclamation label if it is also used as part of the search and replace?
I am trying to replace all esclamation tags with a shielded version so that it can display and work with it.
Btw, are there any existing functions in the package that will remove and allow escaping of all special characters?
Here is some more code that can help explain what I'm doing.
{"Title":"Turk 182!","Year":"1985","Rated":"PG-13","Released":"15 Feb 1985","Runtime":"1 h 42 min","Genre":"Action, Comedy, Drama","Director":"Bob Clark","Writer":"Denis Hamill, James Gregory Kingston","Actors":"Timothy Hutton, Robert Urich, Kim Cattrall, Robert Culp","Plot":"Jimmy Lynch is angry because his older brother, who was injured as a result of an off duty fire rescue...","Poster":"http://ia.media-imdb.com/images/M/ MV5BMTQ2OTk1ODA1MV5BMl5BanBnXkFtZTcwNjYwNjgyMQ@ @._V1_SX300.jpg","imdbRating":"5.7","imdbVotes":"2,360","imdbID":"tt0090217","Response":"True"} rem removes starting and ending brackets set json=%json:~1,-1% setlocal EnableDelayedExpansion rem replace "," with linebreak set json=!json:","="#"! setlocal EnableDelayedExpansion rem replace ! with ^^! set json=%json:!=^^!!% setlocal DisableDelayedExpansion echo %json% echo. exit /b
Then I put the json variable in a loop, and it throws an error instead of the true value. I just see the actual replacement command above.