/    Sign up×
Community /Pin to ProfileBookmark

Youtube phrasing with regexe.

Will this regexe phrase most youtube links or am I missing something?

[CODE]/(w{4}://w{3}.youtube.com/watch?v=w{11})/[/CODE]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Aug 04.2008 — w is a-zA-Z_- so it will not accept numbers which are in Youtube URLs if I recall correctly.

And what is

(w{4}://w{3} Don't forget all the youtube subdomains, and www. is not necessary.
Copy linkTweet thisAlerts:
@Lawrence_FieldsauthorAug 04.2008 — So trying to match http://www. is not needed? Also what should I use in place of w ?
Copy linkTweet thisAlerts:
@Declan1991Aug 04.2008 — Well the problem is that there are also the country specific domains, so you will have to use<i>
</i>http://w{2,3}
for the http://www bit.

Then youtube.com/watch?v= is fine too.

Then to match alphanumerical characters, you have to use [a-zA-Z0-9]. So the final regexp would be<i>
</i>http://w{2,3}.youtube.com/watch?v=[a-zA-Z0-9]{11}

The other things to note are that I have escaped the full stops, because a full stop means any character, and I've done the same for all punctuation because it's the safest.

watch? doesn't match "watch?", it matches "watc" or "watch".
×

Success!

Help @Lawrence_Fields spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...