I'm trying to get subsection of a string(url) that looks like this.
https://justkidding.com/ids/09239849/dont-say-a-word and i want to get 09239849
*The length and value of the 09239849 (substring) varies but the string (url) structure remains the same.
I tried using replace method but i can only get 09239849/dont-say-a-word from the string because everything after the substring (09239849) is dynamic
<!--mycode-->
<button onclick="myFunction()">View ID</button>
<script>
function myTrim(x) {
return x.replace('https://justkidding.com/ids/','');
}
function myFunction() {
var str = myTrim("https://justkidding.com/ids/09239849/dont-say-a-word");
alert(str);
}
</script>