Below is an example of a String that I want to split it to 3 parts from a substring
test01String001s
Examples:
example_1 subString == "0"
res: [ "test","0","1String001s" ] - test01String001s
example_2 subString == "st"
res: [ "te","st","01String001s" ] - test01String001s
example_3 subString == "01s"
res: [ "test01String0","01s", "" ] - test01String001s
example_4 subString == "t"
res: [ "","t","est01String001s", ] - test01String001s
I try to resolve it via
var string='test01String001s'
var keyword="01"
console.log(string.split(keyword));
output:
["test","String0","s"] instead of [ "test","01","String001s"]
or
var string='test01String001s'
var keyword="0"
console.log(string .split(keyword, 2));
output
["test","1String"]
[s.slice(0,i), separator, s.slice(i+1)]