1
http:\/\/embed.(.*).com\/\?id=([0-9]+)

$userAgent  = array('http' => array('user_agent' => 'Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D)'));

is there anyway to get both http and https with the above code?

  • 1
    Possible duplicate of [Learning Regular Expressions](http://stackoverflow.com/questions/4736/learning-regular-expressions) – Biffen Jan 12 '17 at 10:30
  • What has the added code got to do with the question?! – Biffen Jan 12 '17 at 10:47
  • Biffen sorry Im a starter with regex maybe Im wrong but this is the first time that Im working with this type of codes, Im just learning –  Jan 12 '17 at 10:49

1 Answers1

0

Add an optional pattern s? (s will match an s and ? will make the regex engine match it one or zero times):

https?:\/\/embed\.(.*)\.com\/\?id=([0-9]+)
    ^^ 

I also think you forgot to escape the dots after embed and before com. You also might want to replace (.*) with ([^\/]*) to avoid overflowing across / separated URL sections, so consider using

https?:\/\/embed\.([^\/]*)\.com\/\?id=([0-9]+)
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563