I have regex:
preg_match( '/\/user\/([^\/?#]+)/', $url, $matches )
To get the username part of string:
https://www.youtube.com/user/username
So it checks what comes after user
. How do I adjust it so it grabs the username in this example:
https://www.youtube.com/c/username
I've tried adding |c
like this:
'\/user|c\/([^\/?#]+)'
But it doesn't work. What's the accurate approach?