- Batch Script Tutorial
- Batch Script - Home
- Batch Script - Overview
- Batch Script - Environment
- Batch Script - Commands
- Batch Script - Files
- Batch Script - Syntax
- Batch Script - Variables
- Batch Script - Comments
- Batch Script - Strings
- Batch Script - Arrays
- Batch Script - Decision Making
- Batch Script - Operators
- Batch Script - DATE & TIME
- Batch Script - Input / Output
- Batch Script - Return Code
- Batch Script - Functions
- Batch Script - Process
- Batch Script - Aliases
- Batch Script - Devices
- Batch Script - Registry
- Batch Script - Network
- Batch Script - Printing
- Batch Script - Debugging
- Batch Script - Logging
- Batch Script Resources
- Batch Script - Quick Guide
- Batch Script - Useful Resources
- Batch Script - Discussion
Batch Script - Replace a String
To replace a substring with another string use the string substitution feature.
Example
@echo off set str=This message needs changed. echo %str% set str=%str:needs=has% echo %str%
The key thing to note about the above program is, the example replaces the word ‘needs’ with the string ‘has’ via the statement %str:needs = has%
Output
The above command produces the following output.
This message needs changed. This message has changed.
batch_script_strings.htm
Advertisements
To Continue Learning Please Login
Login with Google