JavaScript mendapatkan string antara dua karakter
const oldString = 'John1Doe2'
const stringBetweenCharacters = oldString.match(/1(.*?)2/i)[1] //Doe
Tom Bomb
const oldString = 'John1Doe2'
const stringBetweenCharacters = oldString.match(/1(.*?)2/i)[1] //Doe
//Gets the part of the string inbetween the : and the ;
var part = str.substring(
str.lastIndexOf(":") + 1,
str.lastIndexOf(";")
);
let str = "My string is:abc;";
var mySubString = str.substring(
str.indexOf(":") + 1,
str.lastIndexOf(";")
);
// mySubString = "abc"
var str = 'one:two;three';
str.split(':').pop().split(';')[0]; // returns 'two'