我有正则表达式:
preg_match( '/\/user\/([^\/?#]+)/', $url, $matches )
要获取字符串的用户名部分:
https://www.youtube.com/user/username
所以它检查后面的内容user
。如何调整它以使其在此示例中获取用户名:
https://www.youtube.com/c/username
我试过|c
这样添加:
'\/user|c\/([^\/?#]+)'
但它不起作用。准确的方法是什么?