I want to use YouTube player w/YouTube URLs so trying to use Regex to extract the video id.
I found a Regex pattern that works (it extracts the 11 char video ID from a URL; tested w/a regex pattern tester).
My prob is that when I use …'s value: extract with Regex I get an empty result.
As shown in screenshots, I created a new field (video_userid_test) to test the Regex func’y but when running through the debugger the field always ends up ‘empty.’
I’ve tried :first item, :last item (and no item!)
I’ve tried bracketing pattern with single quotes and slashes.
I’m confident the core of the pattern works but can’t seem to get the regex ‘result’ (ie the video id) into that field. Once there, I’ll then use the video id field in the Youtube player.
https?://(?:[0-9A-Z-]+.)?(?:youtu.be/|youtube.com(?:/embed/|/v/|/watch?v=|/ytscreeningroom?v=|/feeds/api/videos/|/user\S*[^\w-\s]|\S*[^\w-\s]))([\w-]{11})[?=&+%\w-]*
(tested it here: https://www.phpliveregex.com/)
video_userid_test is a ‘text’ field; for now it’s just a temporary dupe of video_id that I use for the actual video player. Just want to get it to work (ie get it to be just the video id) and then will use same logic in that field and remove the video_userid_test field.
So the documented ’ :extract with Regex’ func’y in Bubble doesn’t work at all anymore? Has then been confirmed by @bubble? There are all sorts of comment threads about different regex issues.
Do you know if there’s any other way to extract the video ID from a youtube URL?
actually this seems to be the one that works for most (all?) cases:
(?:youtube(?:-nocookie)?.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu.be/)([^"&?/\s]{11})
I was in touch w/Support and was told that Regex should still be working and I s/submit a bug report as trying to get that ‘Group 1’ may be a new feature that’s needed.
I thought it used to work by retrieving capture groups as list items, no? @NigelG’s comment implies that regex is broken as well. This is rather disconcerting. It’d be good to know that a bug has been officially filed so that it’s on their radar.
Did report it as bug though the the person I was connecting with in Bubble support said she didn’t think there was a regex bug (“hasn’t been touched in while”). Just trying this :extract w/Regex for first time so not an expert though it seems like get the ‘result’ from a regex pattern should be one this func’y does - but what do I know!
She thought this might be a new feature that’s required. Hopefully I’ll hear back soon.
Thanks. I could be mis-remembering how it worked, but I also know that there seems to have been a number of platform issues reported as of late, including regressions like this one where UI fields inexplicably disappeared from the Image element.
It looks like the difference between your pattern and mine is that yours delivers the video ID in both ‘groups’
My prob was I was only getting the video ID in the ‘second’ group and even using :last item wasn’t working. But getting the video ID in both groups, it does the trick!
Thanks much; this should help many of the folks w/this issue of not wanting to have to use the video ID.
Seems like there’s still a Bubble issue in that :extract with Regex can’t get anything beyond the ‘first group’ but this pattern seems to be a way around it.
What I learned is that Bubble returns all matches as a list, whereas I thought it returned all capture groups within a match as a list. And perhaps it did work that way at one time - not sure. I certainly have no reason to doubt @NigelG that something has changed in that regard.
if it did return all matches as a list, I’d think that the :last item on the Regex I had (which had the ID in the ‘second’ item would have worked) but whatev…