I have this batch file, where I am trying to extract a substring but in the end result the %
character is being removed. Eg some%value
becomes somevalue
. I have escaped the &
character but nothing works for the percent character.
setlocal enabledelayedexpansion
For /F "Delims=" %%A In ('FindStr /I "<start>.*</end>" "AllApiLogs.log"') Do (
Call :Sub "%%A"
)
GoTo :EOF
:Sub
Set "Line=%~1"
Set "Line=%Line:&=^&%"
Set "Up2Sub=%Line:*<start>=%"
Set "SubStr=%Up2Sub:</end>="&:"%"
Echo '%SubStr%', >> ApiRegExExtract.log
Exit /B
How do I work around this? Is there a way to escape all characters that need escaping in batch files? I am new to these.