Answers for "how to get substring after character in javascript"

4

get string after character javascript

const str = '01-01-2020';

// get everything after first dash
const slug = str.substring(str.indexOf('-') + 1); // 01-2020

// get everything after last dash 
const slug = str.split('-').pop(); // 2020
Posted by: Guest on July-06-2020
1

get everything after the first character javascript

var val = 'asdasd:111122:123123123';
var response = val.substring(val.indexOf(":"));

alert(response); // ":111122:123123123"
Posted by: Guest on September-16-2020
0

javascript substring after character

var testStr = "sometext-20202"
var splitStr = testStr.substring(testStr.indexOf('-') + 1);
Posted by: Guest on February-12-2021
0

javascript substring after character

// function you can use:
function getSecondPart(str) {
    return str.split('-')[1];
}
// use the function:
alert(getSecondPart("sometext-20202"));
Posted by: Guest on February-12-2021

Code answers related to "how to get substring after character in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language