Skip to content

Instantly share code, notes, and snippets.

@bpongy
Created May 2, 2019 07:40
Show Gist options
  • Save bpongy/964e3c88557710e7c53c405ad73cf634 to your computer and use it in GitHub Desktop.
Save bpongy/964e3c88557710e7c53c405ad73cf634 to your computer and use it in GitHub Desktop.
regex : YouTube URL
<?php
$excerpt = preg_replace('/((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)([a-zA-Z0-9&=?_]+)?/mi', '', $excerpt);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment