php - Regular expression to extract data from a colum and put it in another column -


i have mysql table few columns.

column 1 contains html code:

<p style="xxx"><img src="path/to/file.png(or jpg)"></p> 

i want extract src (path/file.xxx) column 2, , remove whole p tag column 1.

i tried few techniques like

preg_match('/\< *[img][^\>]*[src] *= *[\"\']{0,1}([^\"\']*)/i', $row->image, $matches); 

but nothing seems work.

anything simple , light use?

[] represents character set, not sequence of characters.

$html = '<p style="xxx"><img src="path/to/file.png(or jpg)"></p>'; preg_match('/<img src="([^"]*)">/', $html, $m); echo $m[0] . "\n"; echo $m[1] . "\n"; 

outputs:

<img src="path/to/file.png(or jpg)"> path/to/file.png(or jpg) 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -