//substring() is similar to slice().
//The difference is that start and end values less than 0 are treated as 0 in substring()
let str = "Apple, Banana, Kiwi";
let part = str.substring(7, 13);
// >> Banana
//if you find this answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
var str = "Some String";
public string Substring(int startIndex);
var valueOfSubstring = str.Substring(5);
public string Substring(int startIndex, int length);
var valueOfSubstring = str.Substring(5, 3);
string a = "String";
string b = a.Replace("i", "o"); // Strong
b = a.Insert(0, "My "); // My String
b = a.Remove(0, 3); // ing
b = a.Substring(0, 3); // Str
b = a.ToUpper(); // STRING
int i = a.Length; // 6
//substr() is similar to slice().
//The difference is that the second parameter specifies the length of the extracted part
let str = "Apple, Banana, Kiwi";
let part = str.substr(7, 6);
// >> Banana
//if you find this answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
# To find the index of a substring in another string
# Take for instance, below take two strings: str and substr.
str="hello world"
substr="world"
prefix=${str%%$substr*}
index=${#prefix}
if [[ index -eq ${#str} ]];
then
echo "Substring is not present in string."
else
echo "Index of substring in string : $index"
fi
/*Delimiter variables, first and second position*/
DECLARE @dfp AS CHAR(1);
DECLARE @dsp AS CHAR(1);
DECLARE @text VARCHAR(MAX);
SET @dfp = ';';
SET @dsp = '@';
SET @text = 'I want you to ;Extract this@ substring for me please.';
SELECT SUBSTRING(@text, (CHARINDEX(@dfp, @text) + 1), (CHARINDEX(@dsp, @text) - 2) - CHARINDEX(@dfp, @text) + Len(@dsp))