There are so many ways to extract data from a string whether it be substring, split, etc
. This is an open ended question and may be too open ended, but is there a "right" way to do this? For example I have a URL http://myServer:8000/courses/courseName/courseID
what is the right way to extract out courseID
in this instance?
This is an example of what I have done:
const test2 = test.split('/courses/').slice(1).toString();
const test3 = test2.substring(0, test2.lastIndexOf('/'))
console.log(test3)