Solution Timeline

All versions (edits) of solutions to Get ID from url path - regex appear below in the order they were created. Comments that appear under revisions were those created when that particular revision was current.

To see the revision history of a single solution (with diffs), click on the solution number (ie. "#1") in the upper right corner of a solution revision below.

← Bounty Expand all edits

Will this do?

    http[^#\?]+[^\d](\d{4,7})[^-\d\w]*

You'll need to capture the first group out of it.

Will this do?

    http[^#\?]+[^\d](\d{4,7})(?![-\d\w]+)

You'll need to capture the first group out of it.

Updated.

Tipped

https://regex101.com/r/LkDdb9/2

Something like this?

Winning solution