phpstringreplacepreg-replacesanitization

How to replace a literal string?


I wanted some help regarding REGEX.

I have the following in a string variable after scraping from a website.

16:50 to 17:50 OOPS LAB : Scheduled Class : Shikha Jain : E1-0LA4 Download Course materials 15:45 to 16:45 OOPS LAB : Scheduled Class : Shikha Jain : E1-0LA4 Download Course materials 14:40 to 15:40 FR - III : Scheduled Class : Ravi Shankar Kumar : E3-218 Download Course materials  

What i want to do is, get rid of the " Download Course materials" part. I tried the str_replace and preg_replace but they all kept failing to replace successfully.


Solution

  • Note that the ampersand has been replaced by an entity:   (thanks Viktor) :

    $new_string = str_replace(' Download Course materials', '', $your_string)
    

    Should do the job.