Answers for "check if string ends with value"

2

javascript check if string ends with

function endsWith(str, suffix) {
    return str.indexOf(suffix, str.length - suffix.length) !== -1;
}

endsWith("hello young man","man");//true
endsWith("hello young man","boy");//false
Posted by: Guest on July-24-2019
1

regex ends with string

$ is used to match the end of the string. and can be used like

"string"$
like

xyz$
if you want to end with xzy
Posted by: Guest on December-14-2020

Code answers related to "check if string ends with value"

Code answers related to "Javascript"

Browse Popular Code Answers by Language