I've looked on similiar topics but no one seems to answer my question.
I've URL that looks like this:
https://dummy.com/job/test
I need to extract test so I am using:
 function getIdentificator(){
 let URL = window.location.pathname;
 let Id = URL.slice(URL.lastIndexOf('/') + 1);
 return Id;
}
It gives me what I want but sometimes the URL is different. For example:
 https://dummy.com/job/testwz/something
I only need testwz.
Or:
 https://dummy.com/job/test-ab?somethingmore2132
I only need test-ab.
Or:
 https://dummy.com/job/test
I only need test.
Or:
 https://dummy.com/job/5423
I need 5423 from this.
Value I'm interested in always appear after job/ but in different variations as said before. Key value may be followed by: nothing, / or ?.
Is there any way to extract this value in all examples with JavaScript? If not I can use jQuery as well.
 
     
     
    