I'm trying to create a Custom JavaScript Variable in Google Tag Manager to split up information from a page url that has multiple separators. For example, in <https://website.com/item/2006-yellow-submarine>, I would want to capture the **2006**. I've been using the code below to separate a URL based on one separator at a time (- or /). But if I used the code below to pull 2006, it would pull 2006 and everything after (so the data pulled would be **2006-yellow-submarine** and not **just 2006**).

```
function() {
  var pageUrl = window.location.href;
  return pageUrl.split("/")[4];
}

```

Is there a way to extract only the 2006, or to essentially use a combination of - and / separators to pull single path points from a URL, without having to specify the URL in the code each time?

Since it's a variable meant to be used to automatically capture the year on each page, I can't make a variable for every individual page of the website. Therefore the solution can't involve specifying the URL.