DosTips.com

A Forum all about DOS Batch
It is currently 26 Aug 2016 05:53

All times are UTC-06:00




Post new topic  Reply to topic  [ 7 posts ] 
Author Message
PostPosted: 15 Jun 2012 07:58 
Offline

Joined: 15 Feb 2012 14:02
Posts: 169
How proceed string with double quotes in for loop?

%%A is has this value:

span class="proxy_anonymous" style="font-weight:bold; font-size:10px;"

Code:
SET type=%%A
SET type=!type:"=$!
FOR /F "tokens=1,2 delims=$" %%S IN ("%%A") DO (


And I want to get the name of class, which is here proxy_anonymous


Top
   
PostPosted: 15 Jun 2012 08:07 
Offline
Expert

Joined: 10 Feb 2012 02:20
Posts: 5901
Code:
d:\ABC>type input.txt
span class="proxy_anonymous" style="font-weight:bold; font-size:10px;"
d:\ABC>type a.bat
    @echo off
    for /f "tokens=3 delims== " %%a in (input.txt) do (
    for /f "delims=" %%b in (%%a) do echo %%b
    )
    pause



d:\ABC>a
proxy_anonymous
Press any key to continue . . .


Top
   
PostPosted: 15 Jun 2012 08:18 
Offline

Joined: 15 Feb 2012 14:02
Posts: 169
I know I can do this when I have the string saved in file. But the string is result from the previous loop.


Top
   
PostPosted: 15 Jun 2012 08:23 
Offline
Expert

Joined: 10 Feb 2012 02:20
Posts: 5901
This is simpler anyway.

Code:
d:\ABC>type input.txt
span class="proxy_anonymous" style="font-weight:bold; font-size:10px;"
d:\ABC>type a.bat
    @echo off
    for /f "tokens=3 delims== " %%a in (input.txt) do (
    echo %%~a
    )
    pause



d:\ABC>a
proxy_anonymous


Top
   
PostPosted: 15 Jun 2012 08:59 
Offline

Joined: 15 Feb 2012 14:02
Posts: 169
It doesn't work for me

Code:
    FOR /F "tokens=3 delims== " %%S IN (%%~A) DO (
    SET type=%%S %%T
    )


Span is not a command.

What does the ~ and why do you use = as delimiter?

You take different part than I thought. Does the ~ removes quotes with the style attribute? Still don't understand why 3rd token? It looks like it should be 2nd token. And the command will not go thorough because the string contains quotes.


Top
   
PostPosted: 15 Jun 2012 09:21 
Offline

Joined: 15 Feb 2012 14:02
Posts: 169
Succeed!
Code:
SET A=%%A
SET A=!A:"=$!
FOR /F "tokens=1,2,3 delims=$ " %%S IN ("!A!") DO (
echo %%U


Top
   
PostPosted: 15 Jun 2012 10:45 
Offline
Expert

Joined: 23 Dec 2011 13:59
Posts: 3166
doscode wrote:
It doesn't work for me

Code:
    FOR /F "tokens=3 delims== " %%S IN (%%~A) DO (
    SET type=%%S %%T
    )


Span is not a command.

What does the ~ and why do you use = as delimiter?

You take different part than I thought. Does the ~ removes quotes with the style attribute? Still don't understand why 3rd token? It looks like it should be 2nd token. And the command will not go thorough because the string contains quotes.

Its an EQUALS symbol and a SPACE as the delimiter which makes it the THIRD TOKEN!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 7 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Yahoo [Bot] and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited