Go and check out course on Udemy for PowerShell:
https://www.udemy.com/course/powershe...
Title: BATCH SCRIPTING// REMOVE AND REPLACE IN STRING // Batch Scripting Part 12 REMOVE AND REPLACE IN STRING
In this lesson, you will be learning about REMOVE AND REPLACE IN STRING for Batch Script.
REMOVE: The string substitution feature can also be used to remove a substring from another string.
Example
@echo off
set str = Batch file created here.
echo %str%
set str = %str:file = %
echo %str%
The key thing to note about the above program is, the ‘is’ word is being removed from the string using the :’stringtoberemoved’ = command.
Output
The above command produces the following output.
Batch file created here.
Batch created here.
REMOVE BOTH ENDS : This is used to remove the first and the last character of a string
Example
@echo off
set str = Batch file created here.
echo %str%
set str = %str:~1,-1%
echo %str%
The key thing to note about the above program is, the ~1,-1 is used to remove the first and last character of a string.
Output
The above command produces the following output.
Batch file created here.
atch file created here
REMOVE ALL SPACES: This is used to remove all spaces in a string via substitution.
Example
@echo off
set str = Batch file created here.
echo %str%
set str=%str: =%
echo %str%
The key thing to note about the above program is, the : = operator is used to remove all spaces from a string.
Output
The above command produces the following output.
Batch file created here.
Batchfilecreatedhere.
REPLACE STRING: To replace a substring with another string use the string substitution feature.
Example
@echo off
set str=Batch file created here.
echo %str%
set str=%str:file=files%
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.
Batch file created here.
Batch files created here.
=======================================================
If you have any questions, please post them. Don't forget to comment, like, rate and subscribe
=====================================================
Batch file programming tutorial // CREATE BATCH FILE // Batch Scripting Part-1 -- • Batch file programming tutorial // CREATE ...
Batch file programming tutorial // Batch Scripting Part-2 - Basic Batch Commands -- • Batch file programming tutorial // Batch S...
Batch file programming tutorial // COPY COMMAND // Batch Scripting Part-3 - COPY Batch Command -- • Batch file programming tutorial // COPY CO...
Batch file programming tutorial // DEL COMMAND // Batch Scripting Part-4 - DEL Batch Command -- • Batch file programming tutorial // DEL COM...
Batch file programming tutorial // MOVE COMMAND // Batch Scripting Part-5 - MOVE Batch Command -- • Batch file programming tutorial //MOVE COM...
Batch file programming tutorial // ATTRIB COMMAND // Batch Scripting Part-6 - ATTRIB Batch Command -- • Batch file programming tutorial // ATTRIB ...
Batch file programming tutorial // FIND COMMAND // Batch Scripting Part-7 - FIND Batch Command -- • Batch file programming tutorial // FIND CO...
Batch file programming tutorial // VARIABLES IN BATCH SCRIPT // Batch Scripting Part- 8 - VARIABLES -- • Batch file programming tutorial // VARIABL...
DO NOT CLICK // LOCAL AND GLOBAL VARIABLES IN BATCH SCRIPT // Part- 9 - LOCAL AND GLOBAL VARIABLES -- • DO NOT CLICK // LOCAL AND GLOBAL VARIABLES...
BATCH SCRIPTING // STRINGS IN BATCH SCRIPT // Batch Scripting Part- 10 - STRINGS -- • BATCH SCRIPTING // STRINGS IN BATCH SCRIPT...
BATCH SCRIPTING// LEFT, MID AND RIGHT STRINGS// Batch Scripting Part- 11- LEFT, MID AND RIGHT STRING -- • BATCH SCRIPTING// LEFT, MID AND RIGHT STRI...
======================================================
Check out other videos
WEAPONS THAT CAN DEFEAT THANOS -- https://www.youtube.com/watch?v=nvlez
MS PAINT TRICK -- https://www.youtube.com/watch?v=4IvBC
Matrix Effect -- • Matrix Rain Best Trick// Create Matrix Rai...