Knowledge Walls
John Peter
Pune, Maharashtra, India
Things to Know [cont'd]
Find & Replace String in String manipulation of MS-DOS Commands
32221 Views
How to find and replace string in ms dos command 
This topic is explained about how to find and replace a string in string using ms dos commands. The below syntax to perform find and replace on a string.

Syntax:
%<variable-name>:<find-text>=<replace-text>%

SET aval=welcame to ms-dos
ECHO %aval:came=come%

About aval is variable name. came is search string. come is replace string. So output is "welcome to ms-dos".
Find and Replace string in ms-dos example
@echo off
SET text=Welcame to india
ECHO String is: %text%
ECHO Search string is "came" replace with "come"

ECHO %text:came=come%
SET /p exit=Bye
Output 
String is: Welcame to india
Search string is "came" replace with "come"
Welcome to india
Bye
Next Topics
Next lessons of current book.
String manipulation of MS-DOS Commands
Things to Know of MS-DOS Commands
Previous Topics
Previous lessons of current book.
String manipulation of MS-DOS Commands
String manipulation of MS-DOS Commands
Commands of MS-DOS Commands
Best Lessons of "MS-DOS Commands"
Top lessons which are viewed more times.
Arithmetic Operators of MS-DOS Commands
Arithmetic Operators of MS-DOS Commands
String manipulation of MS-DOS Commands
Relational Operators of MS-DOS Commands
String manipulation of MS-DOS Commands
String manipulation of MS-DOS Commands
Things to Know of MS-DOS Commands
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details