//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 ( ͡~ ͜ʖ ͡°)
const str = 'Mozilla';
console.log(str.substring(1, 3));
// expected output: "oz"
console.log(str.substring(2));
// expected output: "zilla"
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
# 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
var str = "The MEAN stack is MongoDB, Express.js, AngularJS, and Node.js";
str.indexOf('MongoDB') !== -1 // true
str.indexOf('Java') !== -1 //false
str.indexOf('Node', 5) !== -1 //true
/*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))
let text = "Microsoft Google";
text.substr(2, 10);
s ="abcdefghijklmnopqrstuvwxyz"
print(s[0:len(s)])
#prints the entire string from 0 to len(s)-1
s = ' hello '
s = s[3:8] # no crash if s[3:20]
# 'hello'