DEV Community

loading...

Discussion on: Daily Challenge #305 - Remove Anchors from URLs

Collapse
mellen profile image
Matt Ellen

REGEX to the rescue.

function remove_url_anchor(url)
{
  return url.replace(/([^#]*)#.+/, '$1');
}
Enter fullscreen mode Exit fullscreen mode