Something like this will work, but only if you have one line with quotes in the input line:
@echo OFF
SETLOCAL enableextensions enabledelayedexpansion
set TEXT=Foo: Lorem Ipsum 'The quick brown fox' Bar
@echo %TEXT%
for /f "tokens=2 delims=^'" %%A in ("abc%TEXT%xyz") do (
set SUBSTR=%%A
)
@echo %SUBSTR%
Output, quoted string in the middle:
Foo: Lorem Ipsum 'The quick brown fox' Bar
The quick brown fox
Output, quoted string in front:
'The quick brown fox' Bar
The quick brown fox
Output, quoted string at the end:
Foo: Lorem Ipsum 'The quick brown fox'
The quick brown fox
Exit, whole line:
'The quick brown fox'
The quick brown fox
source
share