Skip to content
Advertisement

Regex for youtube channel URL

how can I validate youtube channel URL using REGEX ?

I found this pattern but it doesn’t work properly

JavaScript

Can anyone help me ?

Advertisement

Answer

Your problem is the extra pipe after user/

Here is the corrected regex:

JavaScript

The reason this is a problem is because it make (channel|user) optional.

A better way to write this regex is

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement