First stripslashes() and all newlines [\n\r*]. It makes the regex much easier.
$pattern= "%<img\x20[\w\d\"=\x20]+(src=\x20*\")([/\w\d\.]+)[\"\x20]*/>%i;
preg_match($pattern, $string, $match); If more than one in the string, use
preg_match_all().
Now print_r($match); so you can see the result.
Now, read the doc and see why each term is used. Note, I assumed your string can
have some variation and still be W3C compatible e.g., src="....." and
src= "....", etc. You may need to be able to handle additional variations.
Al........
William Stokes wrote:
Hello,
Can someone here give me a glue how to do the following. I guess I need to
use regular expressions here. I have absolutely zero experience with regular
expressions. (if there's another way to do this I don't mind. I jus need to
get this done somehow :)
I need to strip all characters from the following text string exept the
image path...
"<img width=\"99\" height=\"120\" border=\"0\"
src=\"../../images/new/thumps/4123141112007590373240.jpg\" />"...and then
store the path to DB. Image path lengh can vary so I guess that I need to
extract all characters after scr=\" until next \" or somethig
similar.
Thanks for your advise!
-Will
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php