i’m horrible at regex and have been banging my head against the wall all morning. i want to replace the image width and height in the img tag in an html snippet. i’ve tried different things and i keep screwing up the img tag.
i want to keep the src and any other attributes the same, set the width to 600 pixels and totally remove the height. anyone have a quick solution?
i tried this to find the width, $rxp=‘/<img.?(width\=[\'|"]{0,1}.?[\’|"]{0,1})[\s|>]{1}/i’;, which works, but i can’t figure out how to replace the original img tag and remove the height.
anyone have a cleaner way to do it? Plus I’m not even sure that it’s doing it like I want it. It’s assuming there’s only 1 image tag in the snippet. There could be more images in the snippet.