$re = '/(?:(?!video).)*video\/(\d+)\//m';
$str = 'https://www.iesdouyin.com/share/video/7039240821144702223/?region=CN&mid=7039240839087803150&u_code=19ambj1ae&did=MS4wLjABAAAAif33DuCPz8E4TM8ohLFknanLbAaeYNGHZvIMdpUGZBk&iid=MS4wLjABAAAAbcVu-zX1os-3_V1-tnqKfcfhYUGKXPsJhcECdsvolcDBQetzxujmh6J5MwxRPIAa&with_sec_did=1&titleType=title×tamp=1639030688&utm_campaign=client_share&app=aweme&utm_medium=ios&tt_from=copy&utm_source=copy
{START}(?:(?!{END}).)*{END}';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php