Computing.Net > Forums > Programming > Parse first/last character in batch

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Parse first/last character in batch

Reply to Message Icon

Name: JohnRodey2009
Date: April 6, 2009 at 06:03:36 Pacific
OS: Windows 2003
Subcategory: Batch
Comment:

Can anyone help come up with a solution.

I'm trying to simply parse the quotes from strings read in from a file. Each string starts and ends with a quote ("). I just want to drop the first and last character. I do not want to drop any quote nested inside the string.

Thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: April 6, 2009 at 06:30:39 Pacific
Reply:

:: drop first and last char

@echo off > newfile & setLocal EnableDelayedExpansion

for /f "tokens=* delims=" %%a in (myfile) do (
set str=%%a
set str=!str:~1,199!
set str=!str:~0,-1!
echo !str!>> newfile
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: ghostdog
Date: April 6, 2009 at 17:52:56 Pacific
Reply:

if you can download tools like sed for windows (check my sig), then this is all you need

c:\> sed -i.bak "s/\"//g" file

Unix Win32 tools | Gawk for Windows


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


batch script to replace f... Batch file drive loop



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Parse first/last character in batch

Using the arrow character in batch. www.computing.net/answers/programming/using-the-arrow-character-in-batch/18976.html

Special characters in batch www.computing.net/answers/programming/special-characters-in-batch/19558.html

asp sql - sql query for last char in a string www.computing.net/answers/programming/asp-sql-sql-query-for-last-char-in-a-string/18767.html