How to use substring operation in String Function Using XPath in Xml

In this article I will explain substring operation of string function.
  • 1952

Introduction

The substring function can take three argument, the first argument describe the substring that is to be returned, the second argument is the position specified in the first argument that means where to start in first argument and the third argument contain the number of letters that the substring contains ,or we can say that  Substring function is used to returns the substring of the first argument starting at the position specified in the second argument and the length specified in the third argument.

Each character in the first string argument is contained a numeric position that means the first character or letter is in the 1st position ,the second character is in the 2nd position and so on.

Syntax

string substring (string, string, string)

Hear substring is the string function which is used to provide the substring based on the second and third argument of the substring function.
If the third argument is not present in the substring than the string it return is start from the position that specify in the second argument string and continue at the end of the string.

Example 1

substring("987654",7,3)
substring("987654",7)

Output
765
7654

If I give the second argument as a floating point number than it will round-off that number and than start from that number and give string until the third argument is obtained, and if the third argument is also floating point than it will also rounded-off.

Example 2
 
substring("987654",8.5,3)
substring("987654",8.5,1.6)

Output
987
98


Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.