Skip to main content
edited tags
Link
200_success
  • 145.6k
  • 22
  • 191
  • 481
added 3 characters in body
Source Link
Brett
  • 165
  • 1
  • 6

I'm looking to pull all the youtube links from a string of text and was wondering how does this look?

if (preg_matchpreg_match_all('/(https?:\/\/)?(www\.)?(youtube\.com)\/watch\?v=([a-zA-Z0-9_-]+)[^\s]*/gim'im', $this->content, $matches)) {
    
}

Obviously this doesn't take into account the youtu.be links as they are formatted differently.

I'm looking to pull all the youtube links from a string of text and was wondering how does this look?

if (preg_match('/(https?:\/\/)?(www\.)?(youtube\.com)\/watch\?v=([a-zA-Z0-9_-]+)[^\s]*/gim', $this->content, $matches)) {
    
}

Obviously this doesn't take into account the youtu.be links as they are formatted differently.

I'm looking to pull all the youtube links from a string of text and was wondering how does this look?

if (preg_match_all('/(https?:\/\/)?(www\.)?(youtube\.com)\/watch\?v=([a-zA-Z0-9_-]+)[^\s]*/im', $this->content, $matches)) {
    
}

Obviously this doesn't take into account the youtu.be links as they are formatted differently.

deleted 6 characters in body
Source Link
Brett
  • 165
  • 1
  • 6

I'm looking to pull all the youtube links from a string of text and was wondering how does this look?

if (preg_match('/(https?:\/\/)?(www\.)?(youtube\.com)\/[^\s]*watch\watch\?v=([a-zA-Z0-9_-]+)[^\s]*/gim', $this->content, $matches)) {
    
}

Obviously this doesn't take into account the youtu.be links as they are formatted differently.

I'm looking to pull all the youtube links from a string of text and was wondering how does this look?

if (preg_match('/(https?:\/\/)?(www\.)?(youtube\.com)\/[^\s]*watch\?v=([a-zA-Z0-9_-]+)[^\s]*/gim', $this->content, $matches)) {
    
}

Obviously this doesn't take into account the youtu.be links as they are formatted differently.

I'm looking to pull all the youtube links from a string of text and was wondering how does this look?

if (preg_match('/(https?:\/\/)?(www\.)?(youtube\.com)\/watch\?v=([a-zA-Z0-9_-]+)[^\s]*/gim', $this->content, $matches)) {
    
}

Obviously this doesn't take into account the youtu.be links as they are formatted differently.

Source Link
Brett
  • 165
  • 1
  • 6
Loading