Command Prompt for Windows




SUBSTR Example

Example 1:

To extract the first 5 characters from the text string 'abcdefgh', enter at the command prompt :-

SUBSTR 1 5 abcdefgh

The environment variable SUBSTR will be set to 'abcde'.

Example 2:

To extract 5 characters from the text string 'abcdefgh', start from the third character, enter at the command prompt :-

SUBSTR 3 5 abcdefgh

The environment variable SUBSTR will be set to 'cdefg'.

Example 3:

To extract 5 characters from the end of the text string 'abcdefgh' , enter at the command prompt :-.

SUBSTR -1 5 abcdefgh

The environment variable SUBSTR will be set to 'defgh'.

Example 4:

To extract 5 character from the text string 'abcdefg', starting at the third last character in the string, enter at the command prompt :-

SUBSTR -3 5 abcdefgh

The environment variable SUBSTR will be set to 'bcdef'.