I want to change image name in img tag using reg exp. <img src="images/abc.jpg" alt="" border="0" align="left"> HTML: Is it possible using reg exp?
what is reg exp? i know exp = exponent, etc.. but reg exp? dont think that there had a predefined function called reg can you please explain more?? more detailed.
part of a larger chunk. A string returned from file_get_contents. How it is possible? Any code sample?
I don't have the code to replace the src, I do have the code to first get the actual image tag (which I pulled from another site yesterday) So we can try it first. It may not be correct though. preg_match_all('/<img[^>]*>/Ui', $content, $matches); Ok, that worked to get the img tag itself. I'm sure there's a better way to do this but this did work ... $content = 'This is a test. <img src="images/foo.jpg" title="foo">'; $res = preg_match_all('/<img[^>]*>/Ui', $content, $matches); $string = $matches[0][0]; $replacement = 'src="images/bar.jpg"'; $pattern = '/src=\"\S*\"/Ui'; echo preg_replace($pattern, $replacement, $string); PHP: