Right now, I'm trying to take a URL in this format:
https://www.example.com/{section}/posts/{number}
and get section and number. I need to do it with a regex; I cannot just break it into a parts array. I have tried:
var sect = myURL.match('https://www.example.com/[^/]+');
but I get as output "https://www.example.com/{section}"
. I want to be able to get the section
and the number
. How do I do this in JavaScript?
Copyright Notice:Content Author:「user11039951」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/66013555/how-do-i-use-a-regex-in-javascript-to-extract-specific-parts-of-a-url-path