Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript substring after character

var testStr = "sometext-20202"
var splitStr = testStr.substring(testStr.indexOf('-') + 1);
Comment

javascript substring after character

// function you can use:
function getSecondPart(str) {
    return str.split('-')[1];
}
// use the function:
alert(getSecondPart("sometext-20202"));
Comment

javascript substring after character

const str = 'sometext-20202';
const slug = str.split('-').pop();
Comment

PREVIOUS NEXT
Code Example
Javascript :: angular one array contains any of second 
Javascript :: jquery open image in new tab 
Javascript :: get value before change and after change js 
Javascript :: javascript date minus minutes 
Javascript :: jquery change picture onclick 
Javascript :: ajax authorization header token 
Javascript :: js multiply string 
Javascript :: js decrement for loop 
Javascript :: js omit last string 
Javascript :: javascript add element above 
Javascript :: js replace characters in a string 
Javascript :: how to add parameters to url javascript 
Javascript :: how to remove menu bar in electron app without removing frame 
Javascript :: javascript remove text from string 
Javascript :: sort array by date 
Javascript :: discord.js random message 
Javascript :: vuejs scrollBehavior 
Javascript :: split a message js 
Javascript :: subtract two date javascript 
Javascript :: send multiple files using formdata jquery 
Javascript :: jquery 3.6.0 cdn 
Javascript :: js save files 
Javascript :: how to return ascending array using for loop in js 
Javascript :: style react background 
Javascript :: multi-line javascript 
Javascript :: how to cut a string in js 
Javascript :: js string array convert to int 
Javascript :: Truncate a string-Javascript 
Javascript :: convert a string to an integer in javascript 
Javascript :: how to display text with formating react js 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =