The magic is in the .* and don’t forget the U at the end to control the greedy.
<? $string = $post_vid_src; $pattern = '/width=".*"/U'; $replacement = 'width="376px"'; $pattern2 = '/height=".*"/U'; $replacement2 = 'height="300px"'; $new_string = preg_replace($pattern, $replacement, $string, -1); $new_string = preg_replace($pattern2, $replacement2, $new_string, -1); echo $new_string; ?>