# Regex - Get ID from URL

**URL:** <https://forum.bubble.io/t/regex-get-id-from-url/229802>\
**Category:** Need help\
**Created:** [October 25, 2022, 9:52pm UTC](https://forum.bubble.io/t/regex-get-id-from-url/229802 "2022-10-25T21:52:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rosshelton](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@rosshelton](https://forum.bubble.io/u/rosshelton)\
**Post date:** [October 25, 2022, 9:52pm UTC](https://forum.bubble.io/t/regex-get-id-from-url/229802/1 "2022-10-25T21:52:29Z")

</div>

Hi all,

Does anyone know a good regex to extract the following ID number from the URL?

[https://www.shutterstock.com/video/clip-](https://www.shutterstock.com/video/clip-) **1076280362** -bullet-casing-falling-wet-ground-crime-scene

I appreciate all the help! I’ve been searching and testing but can’t crack this one.

---

<div class="post-metadata">

**Author:** ![mikeloc](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mikeloc/32/93001_2.png) [@mikeloc](https://forum.bubble.io/u/mikeloc)\
**Post date:** [October 25, 2022, 10:06pm UTC](https://forum.bubble.io/t/regex-get-id-from-url/229802/2 "2022-10-25T22:06:49Z")

</div>

Hi there, @rosshelton… if the format is always the same, you could use Bubble’s _:split by_ operator, with the character to split by being a dash. Then, add the _:item #_ operator to the end of the expression and set the item number as 2, and you should get the ID number in return.

Hope this helps.

Best…  
Mike

---

<div class="post-metadata">

**Author:** ![rosshelton](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@rosshelton](https://forum.bubble.io/u/rosshelton)\
**Post date:** [October 25, 2022, 10:10pm UTC](https://forum.bubble.io/t/regex-get-id-from-url/229802/3 "2022-10-25T22:10:33Z")

</div>

Thanks Mike!

I’m trying to achieve the the whole thing using regex. I will have multiple url types with IDs in different places. I will need to use the same extract with Regex workflow but with a different regex patterns for the different URLs.

I appreciate your thought!

---

<div class="post-metadata">

**Author:** ![mikeloc](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mikeloc/32/93001_2.png) [@mikeloc](https://forum.bubble.io/u/mikeloc)\
**Post date:** [October 25, 2022, 10:18pm UTC](https://forum.bubble.io/t/regex-get-id-from-url/229802/4 "2022-10-25T22:18:29Z")

</div>

Okay, I will give it one more shot.

I don’t pretend to be a regex expert, but a quick text using the _:extract with Regex_ operator on your URL with the super simple regex of `[0-9]+` extracted the ID number. If’ that’s not what you need, then I’m out. 🙂

---

<div class="post-metadata">

**Author:** ![rosshelton](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@rosshelton](https://forum.bubble.io/u/rosshelton)\
**Post date:** [October 25, 2022, 10:20pm UTC](https://forum.bubble.io/t/regex-get-id-from-url/229802/5 "2022-10-25T22:20:50Z")

</div>

It’s possible that the name may have numbers in them.

[https://www.shutterstock.com/video/clip-1076280362-](https://www.shutterstock.com/video/clip-1076280362-) **bullet-casing-falling-wet-ground-crime-**

---

<div class="post-metadata">

**Author:** ![rosshelton](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@rosshelton](https://forum.bubble.io/u/rosshelton)\
**Post date:** [October 25, 2022, 10:24pm UTC](https://forum.bubble.io/t/regex-get-id-from-url/229802/6 "2022-10-25T22:24:00Z")

</div>

> [@mikeloc](#):
>
> [0-9]+

Although, maybe that is the winner. It seems to only match the first instance. 😀

---

<div class="post-metadata">

**Author:** ![mikeloc](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mikeloc/32/93001_2.png) [@mikeloc](https://forum.bubble.io/u/mikeloc)\
**Post date:** [October 25, 2022, 10:27pm UTC](https://forum.bubble.io/t/regex-get-id-from-url/229802/7 "2022-10-25T22:27:37Z")

</div>

Another quick test on this end shows that it will find additional strings of numbers, and they will be comma separated. So, if you add the _:first item_ operator to the end of the expression, you could have what you need.

---

<div class="post-metadata">

**Author:** ![rosshelton](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@rosshelton](https://forum.bubble.io/u/rosshelton)\
**Post date:** [October 25, 2022, 10:29pm UTC](https://forum.bubble.io/t/regex-get-id-from-url/229802/8 "2022-10-25T22:29:05Z")

</div>

I was just seeing the same. I think the first item trick might be a winner on this!

Thanks so much!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [January 3, 2023, 9:52pm UTC](https://forum.bubble.io/t/regex-get-id-from-url/229802/9 "2023-01-03T21:52:36Z")

</div>

This topic was automatically closed after 70 days. New replies are no longer allowed.
