Having some difficulty using JavaScript regex to extract a specific part of a URL while excluding characters that come after it. Here is my current progress:
URL:
With the code snippet url.match(/\/[^\/]+$/)[0]
, I am able to successfully extract "state-de".
However, when the URL changes to and I apply the same regex pattern, it captures everything including "?page=r", which is undesired. My goal is to only capture "state-de" regardless of what comes after it (typically a "?" symbol).