-2

I am parsing the url using regex. Some urls is not showing completely. I am using the following code.

it is working if the $string value is following

$string= "[video width="1280" height="720" mp4="http://egghead-site.s3.amazonaws.com/samples/DOS.mp4" title="DOS Software"][/video]" ; 

if the mp4 value is following then it is not working. it is returning the half url only.

$string =[video width="1280" height="720" mp4="http://egghead-site.s3.amazonaws.com/samples/Colon%20Health%20Final%20V3.mp4" title="Synergi" ][/video]";  

$imageurl = !empty( $string ) ? preg_match_all('@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)@', $string , $match) : '';

return isset($match[0][0]) ? ut_portfolio_add_http($match[0][0]) : '';

I wanna to get the video url. I am new in regex so that I stuck at this point. Please let me know how can I get it in both cases.

lowerends
  • 4,881
  • 2
  • 19
  • 32

1 Answers1

0

I just did a small change to your regex and it seems to be picking up exactly what you want. See here:

((https?:\/\/)+(.+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)
IronWilliamCash
  • 499
  • 4
  • 15