To get the substring after a specific character in JavaScript, you can use the `substring` method along with the `indexOf` method to find the position of the character.
In this example,
url
with a value of "https://example.com/page"
.substring
method with the index of '/'
plus 1 to get the substring after the specified character.let url = 'https://example.com/page';
let substring = url.substring(url.indexOf('/') + 1);
console.log('Substring after / : ' + substring);
Substring after / : /example.com/page
In this example,
str
with a value of "Hello,World"
.substring
method with the index of ','
plus 1 to get the substring after the specified character.let str = 'Hello,World';
let substring = str.substring(str.indexOf(',') + 1);
console.log('Substring after , : ' + substring);
Substring after , : World
In this tutorial, we learned How to get Substring after Specific Character in JavaScript language with well detailed examples.