3v4l.org

run code in 500+ PHP versions simultaneously
<?php $strings = [ "https://www.instagram.com/p/BxKRx5CHn5i/", "https://www.instagram.com/p/BrODg5XHlE6/?utm_source=ig_share_sheet&igshid=znsinsart176", "https://www.instagram.com/p/BxKRx5CHn5i/", "https://www.instagram.com/username/p/BxE5PpZhoa9/", "https://www.instagram.com/username/p/BxE5PpZhoa9/#look=overhere" ]; foreach ($strings as $string) { echo preg_match('~(?:https?://)?(?:www\.)?instagram\.com(?:/[^/]+)*/\K\w+~', $string , $m) ? $m[0] : ''; echo " (from $string)\n"; }
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
BxKRx5CHn5i (from https://www.instagram.com/p/BxKRx5CHn5i/) BrODg5XHlE6 (from https://www.instagram.com/p/BrODg5XHlE6/?utm_source=ig_share_sheet&igshid=znsinsart176) BxKRx5CHn5i (from https://www.instagram.com/p/BxKRx5CHn5i/) BxE5PpZhoa9 (from https://www.instagram.com/username/p/BxE5PpZhoa9/) BxE5PpZhoa9 (from https://www.instagram.com/username/p/BxE5PpZhoa9/#look=overhere)

preferences:
75.64 ms | 1776 KiB | 4 Q