Page 1 of 1

for /F "delims=text" comment

Posted: 12 Jul 2013 13:40
by foxidrive
Well, well well.

Hands up who knew that the delimiters in a for /F were case sensitive? I didn't.

Code: Select all

@echo off
for /f "delims=abc" %%a in ("ABCabc") do set "var=%%a"
echo "%var%"
pause


It returns:

"ABC"


It has been 10 or more years that I've been using delims and never have I struck an instance where the case was an issue - luck I guess.

Re: for /F "delims=text" comment

Posted: 12 Jul 2013 15:01
by Endoro
I knew it. We had this recently at stackoverflow :wink:

Re: for /F "delims=text" comment

Posted: 12 Jul 2013 15:06
by Squashman
I kind of assumed it but never tested it because the token variables are case sensitive I would assume the delims are as well.

Re: for /F "delims=text" comment

Posted: 12 Jul 2013 17:26
by foxidrive
Endoro wrote:I knew it. We had this recently at stackoverflow :wink:


Yes indeed. I added my own bit too and didn't realise that Aacini's was spot on.

Squashman wrote:I kind of assumed it but never tested it because the token variables are case sensitive I would assume the delims are as well.


It's actually more useful being case sensitive. Can't get over it being something so obvious but I never struck it until today. :)
I was filtering out characters from a DATE command and tripped over it...