Batch Language: Extracting a substring from a string!

Subscribers:
613
Published on ● Video Link: https://www.youtube.com/watch?v=x4qjxi5fIP8



Duration: 17:00
141 views
1


Hello, Batch programmer, welcome to extracting substring from a string!

Batch extracting a substring from a string is uniqe. You need to understand it.
There are 5 types syntax or command:
1. %variable:~num_char_to_skip%
2. %variable:~num_char_to_skip,num_char_to_keep%
3. %variable:~num_char_to_skip,-num_char_to_keep%
4. %variable:~-num_char_to_skip,num_char_to_keep%
5. %variable:~-num_char_to_skip,-num_char_to_keep%

There are two variable here:
1. num_char_to_skip
2. num_char_to_keep

1. The value of variable num_char_to_skip are varying between + (positive), 0 and - (negative).
2. The value of variable num_char_to_keep are varying between + (positive), 0 and - (negative), also.

From now let us call num_char_to_skip as left variable and num_char_to_keep as right variable, to shorten the writing the variable name.

So,
If the left variable is positive then the batch programming will start to count characters to skip from left of the original string. If the left variable is negative then the batch programming will start to count characters to skip from the right of the original string.

But, it is a little different with the right variable.
If the right variable is positive then the batch programming will start to count character to keep from the first character after the left variable points to, and it is not always from the beginning of the original string depends on the value of the left variable points to.
If the right variable is negative then batch programming will start to count character to keep from the
right of the original string. It is much like skipping characters.

You can read it more in here:
https://ss64.com/nt/syntax-substring.html







Tags:
batch programming
extracting substring
batch
batch programmer
ss67.com
batch language
batch scriping