0

I'm working with an image that's processed through a long script in which I cannot modify the function so I'm looking to simply process it's output afterwards with a regex. Here's what I've got:

I have the following regex pattern:

'width\=\"(.*?)\"\sheight\=\"(.*?)\"'

I'm trying to remove the width and height from an image tag much like this:

<img width="706" height="452" src="/images/logos/partner.png" />

When using preg_replace function like so:

$img['thumbnail'] = preg_replace(
    'width\=\"(.*?)\"\sheight\=\"(.*?)\"',
    '', 
    $img['thumbnail']);

However this returns NULL.

I've tested this using https://regex101.com/ and it appears to be valid. What am I missing?

Chris Stage
  • 187
  • 12

0 Answers0