How to extract the desired part from the links?

There are several types of links to clips twitch
or so

You need to pull the part in bold. Tell me how.
April 4th 20 at 00:38
3 answers
April 4th 20 at 00:40
$string = '
or so

if(preg_match_all('/twitch\.tv\/(?:[^\/]+\/clip\/)?([0-9a-z]+)/uis', $string, $matches)) {
April 4th 20 at 00:42
preg_match('~(?<=\/)\w+(?=\?|$)~', $str, $match);
$result = $match[0];
Only works it without checking for domain. Thank you! - Candice commented on April 4th 20 at 00:45
@Candice, that is, to clearly formulate the essence of their problems you don't know about the "test domain" speech in the original question was not. - dale_Kub commented on April 4th 20 at 00:48
April 4th 20 at 00:44
Of course, let's regexps to do the standard things
$url = '';
 basename(parse_url($url, PHP_URL_PATH))

"You have a problem. You decided to use regular expressions to solve it. Now you have two problems.”
I haven't used so far that even regular expression) - Candice commented on April 4th 20 at 00:47

Find more questions by tags PHP