Regex for recognizing space in file name
<p>I want to use regex to recognize space in the .pdf file name</p>

<p>So far i have been able to recognize src link to the file but it does not recognize the spaces in file name.</p>

<pre><code>   &lt;?php
   echo "&lt;h1&gt;Reading content from ITM website!&lt;/h1&gt;";
   $ch = curl_init("http://domain.edu/index.php?option=com_content&amp;view=article&amp;id=58&amp;Itemid=375&amp;alias=lms");
   $fp = fopen("example_homepage.txt", "w");

   curl_setopt($ch, CURLOPT_FILE, $fp);
   curl_setopt($ch, CURLOPT_HEADER, 0);

   curl_exec($ch);
   curl_close($ch);
   $my_file="example_homepage.txt";
   $handle = fopen($my_file, 'rb');
   $data = fread($handle,filesize($my_file));

   $contents = strstr(file_get_contents('example_homepage.txt'), 'More quick links');
   $new_content = str_replace('&lt;a href="', '&lt;a href="http://www.domain.edu', $contents);
   $regex = '@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.\,]*(\?\S+)?)?)*)@';
   $text = preg_replace($regex, '&lt;a href="$1"&gt;$1&lt;/a&gt;', $new_content);
   //echo $new_content;
   echo $text;
   fclose($fp);
   ?&gt;
</code></pre>

<p>Current Output: </p>

<pre><code>http://www.domain.edu/academiccalendar/Notice for final practical.pdf" target="_blank"&gt;Title
</code></pre>

<p>In this "Notice for final practical.pdf" does not appear as URL and just appears as text. </p>
